public static void writeFile ( byte [ ] bytes , String targetFileName ) throws OSHelperException { FileOutputStream fos ; try { fos = new FileOutputStream ( targetFileName ) ; } catch ( FileNotFoundException ex ) { throw new OSHelperException ( "Received a FileNotFoundException when trying to open target file " + targetFileName + "." , ex ) ; } try { fos . write ( bytes ) ; } catch ( IOException ex ) { throw new OSHelperException ( "Received an IOException when trying to write to target file " + targetFileName + "." , ex ) ; } finally { try { fos . close ( ) ; } catch ( IOException ex ) { throw new OSHelperException ( "Received an IOException when trying to close FileOutputStream for target file " + targetFileName + "." , ex ) ; } } }
Write a file