private synchronized void openFile ( ) { try { String fName = _directory . getAbsolutePath ( ) + File . separatorChar + StreamLoader . FILE_PREFIX + _stamp + _fileCount ; if ( _loader . _compressDataBeforePut ) { fName += StreamLoader . FILE_SUFFIX ; } LOGGER . debug ( "openFile: {}" , fName ) ; OutputStream fileStream = new FileOutputStream ( fName ) ; if ( _loader . _compressDataBeforePut ) { OutputStream gzipOutputStream = new GZIPOutputStream ( fileStream , 64 * 1024 , true ) { { def . setLevel ( ( int ) _loader . _compressLevel ) ; } } ; _outstream = new BufferedOutputStream ( gzipOutputStream ) ; } else { _outstream = new BufferedOutputStream ( fileStream ) ; } _file = new File ( fName ) ; _fileCount ++ ; } catch ( IOException ex ) { _loader . abort ( new Loader . ConnectionError ( Utils . getCause ( ex ) ) ) ; } }
Create local file for caching data before upload