private FileOutputStream fos ( ) throws IOException { if ( closed ) throw new IOException ( "Output stream is already closed" ) ; if ( os == null || currFileBytesWritten >= partSize ) { if ( os != null ) { os . close ( ) ; // notify about the new file ready for processing observer . onPartCreate ( new PartCreationEvent ( getFile ( filesCreated ) , filesCreated , false , this ) ) ; } currFileBytesWritten = 0 ; filesCreated ++ ; blockIfNecessary ( ) ; final File file = getFile ( filesCreated ) ; os = new FileOutputStream ( file ) ; } return os ; }
Returns the file output stream to be used for writing blocking if necessary if running out of disk space .