private void extractFile ( InputStream stream , File dir ) throws IOException { byte [ ] header = new byte [ 8 ] ; byte [ ] fileName = new byte [ 13 ] ; byte [ ] dataSize = new byte [ 4 ] ; stream . read ( header ) ; stream . read ( fileName ) ; stream . read ( dataSize ) ; int dataSizeValue = getInt ( dataSize , 0 ) ; String fileNameValue = getString ( fileName , 0 ) ; File file = new File ( dir , fileNameValue ) ; if ( dataSizeValue == 0 ) { FileHelper . createNewFile ( file ) ; } else { OutputStream os = new FileOutputStream ( file ) ; FixedLengthInputStream inputStream = new FixedLengthInputStream ( stream , dataSizeValue ) ; Blast blast = new Blast ( ) ; blast . blast ( inputStream , os ) ; os . close ( ) ; } }
Extracts the data for a single file from the input stream and writes it to a target directory .