List of utility methods to do Byte Array Save to File nio
void | fileWriteBytes(byte[] data, String file) file Write Bytes File f = new File(file); if (f.exists()) if (!f.delete()) throw new IOException("Unable to delete file."); Files.write(Paths.get(file), data, StandardOpenOption.CREATE, StandardOpenOption.WRITE); |
void | writeBytes(final byte[] bytes, final OutputStream output) write Bytes try (final ByteArrayInputStream input = new ByteArrayInputStream(bytes)) { transfer(input, output); |
void | writeHeader(File input, ByteArrayOutputStream headerStream) write Header try { BufferedReader br = new BufferedReader(new FileReader(input)); StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) sb.append(line).append(String.format(System.lineSeparator())); br.close(); FileOutputStream outFileStream = new FileOutputStream(input); ... |
void | writeIntChars(int value, int index, byte[] buf) Write the characters that make up this integer into the buffer Note: index is the ending location in the buffer. if (value == Integer.MIN_VALUE) { System.arraycopy(INT_MIN_VALUE_BYTES, 0, buf, index - INT_MIN_VALUE_BYTES.length, INT_MIN_VALUE_BYTES.length); } else { getIntChars(value, index, buf); |
boolean | writeToBinaryFile(String filename, byte[] data) Writes the binary data to the specified file. return writeToBinaryFile(filename, data, false);
|
void | writeToFile(File file, byte[] content) Write function for JVM >= 1.7 Files.write(Paths.get(file.getPath()), content, StandardOpenOption.SYNC, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE); |