List of utility methods to do ByteBuffer Save
void | save(Path path, ByteBuffer bb) Writes the remaining bytes of a byte buffer to the given file. try (FileChannel fc = FileChannel.open(path, WRITE, CREATE)) {
fc.truncate(bb.remaining());
fc.write(bb);
|
void | saveAsBMP(String filename, ByteBuffer pixel_data, int width, int height) save As BMP long before = System.currentTimeMillis(); int pad = 4 - (width * 3) % 4; if (pad == 4) pad = 0; int size = (width * 3 + pad) * height + 54; ByteBuffer buffer = ByteBuffer.allocate(size); buffer.put((byte) 0x42); buffer.put((byte) 0x4D); ... |
void | saveAsFile(File targetFile, ByteBuffer bb) save As File FileOutputStream fos = new FileOutputStream(targetFile); try { FileChannel wChannel = fos.getChannel(); while (bb.hasRemaining()) { wChannel.write(bb); wChannel.close(); } finally { ... |
File | saveAsTempFile(ByteBuffer byteBuffer, String extension) Saves the ByteBuffer as a temporary file in the default location final File tempFile = File.createTempFile("tmp", extension); try (FileOutputStream os = new FileOutputStream(tempFile)) { final FileChannel channel = os.getChannel(); channel.write(byteBuffer); channel.force(true); return tempFile; |
void | saveAsTGA(String filename, ByteBuffer pixel_data, int width, int height) save As TGA long before = System.currentTimeMillis(); try (FileOutputStream fout = new FileOutputStream(filename + ".tga")) { fout.write(0); fout.write(0); fout.write(2); fout.write(0); fout.write(0); fout.write(0); ... |
String | saveBytesBufferToFile(ByteBuffer buf, String filename) save Bytes Buffer To File return saveBytesBufferToFile(buf, new File(filename)); |
void | savePageBitMask(ByteBuffer buffer, BitSet freePagesBitSet) save Page Bit Mask buffer.position(Integer.BYTES); buffer.put(freePagesBitSet.toByteArray()); |
void | saveStruct(ByteBuffer o, String[] struct, Object instance) save Struct try { Class instClass = instance.getClass(); for (String s : struct) { String[] args = s.split(" "); if (args[0].equals("size")) { } else if (args[0].equals("data")) { o.put(Long.decode(args[1]).byteValue()); } else if (args[0].equals("skip")) { ... |