The list of methods to do ByteBuffer Save are organized into topic(s).
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
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
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")) {
...