code: public static void write(File file, byte[] data, boolean append) throws IOException {
          FileOutputStream stream = new FileOutputStream(file, append);
          try {
              stream.write(data);
          } finally {
              stream.close();
          }
      }
docs: Writes the given data to the file; either in append mode or replace mode depending
  the append flag