public static boolean byteArrayToFile(final byte[] array,final File targetFile,final boolean doAppend){
  if (array == null || array.length == 0 || !isWritable(targetFile,true)) {
    Log.e(FileUtils.class,"byteArrayToFile(): Null parameter or can't make path dirs");
    return false;
  }
  if (targetFile.exists() && !targetFile.delete())   return false;
  boolean isSucceed=false;
  OutputStream outputStream=null;
  try {
    outputStream=new FileOutputStream(targetFile,doAppend);
    outputStream.write(array);
    isSucceed=true;
    outputStream.flush();
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
 finally {
    if (outputStream != null)     try {
      sync(outputStream);
      outputStream.close();
    }
 catch (    IOException e) {
    }
  }
  return isSucceed;
}

public static boolean byteArrayToFile ( final byte [ ] array , final File targetFile , final boolean doAppend ) { if ( array == null || array . length == 0 || ! isWritable ( targetFile , true ) ) { Log . e ( FileUtils . class , "byteArrayToFile(): Null parameter or can't make path dirs" ) ; return false ; } if ( targetFile . exists ( ) && ! targetFile . delete ( ) ) return false ; boolean isSucceed = false ; OutputStream outputStream = null ; try { outputStream = new FileOutputStream ( targetFile , doAppend ) ; outputStream . write ( array ) ; isSucceed = true ; outputStream . flush ( ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { if ( outputStream != null ) try { sync ( outputStream ) ; outputStream . close ( ) ; } catch ( IOException e ) { } } return isSucceed ; }
writes a byte array to a file .
