I am wondering why with the following code:
SeekableByteChannel seeka = Files.newByteChannel(path,StandardOpenOption.CREATE,StandardOpenOption.WRITE);
ByteBuffer src = ByteBuffer.allocate(10);
src.putChar('a');
src.flip();
seeka.write(src);
I get written in the file (path) the following result: \00a.
I had expected it would have been different, like only the char 'a'.
If I use a CharBuffer than I cannot pass it to the seeka.write()
method.
I am making some experiments with these classes, I am aware that there are other ways to write a char or anything else in a file.
Thanks in advance.