Coverage Report - org.mule.model.streaming.DeleteOnCloseFileInputStream
 
Classes in this File Line Coverage Branch Coverage Complexity
DeleteOnCloseFileInputStream
0%
0/8
0%
0/2
1.5
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.model.streaming;
 8  
 
 9  
 import java.io.File;
 10  
 import java.io.FileInputStream;
 11  
 import java.io.FileNotFoundException;
 12  
 import java.io.IOException;
 13  
 
 14  
 /**
 15  
  * FileInputStream which deletes the underlying file when the stream is closed.
 16  
  */
 17  
 public class DeleteOnCloseFileInputStream extends FileInputStream
 18  
 {
 19  
     private File file;
 20  
 
 21  
     /**
 22  
      * Builds a {@link DeleteOnCloseFileInputStream}.
 23  
      *
 24  
      * @param file #see
 25  
      * @throws java.io.FileNotFoundException If there is a problem regarding the file.
 26  
      */
 27  
     public DeleteOnCloseFileInputStream(File file) throws FileNotFoundException
 28  
     {
 29  0
         super(file);
 30  0
         this.file = file;
 31  0
     }
 32  
 
 33  
     public void close() throws IOException
 34  
     {
 35  
         try
 36  
         {
 37  0
             super.close();
 38  
         }
 39  
         finally
 40  
         {
 41  0
             if (file != null)
 42  
             {
 43  0
                 file.delete();
 44  0
                 file = null;
 45  
             }
 46  
         }
 47  0
     }
 48  
 }