• Post Reply Bookmark Topic Watch Topic
  • New Topic

[Java NIO] MappedByteBuffer does not write all bytes

 
Satish Chilukuri
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm seeing some weird behavior with MappedByteBuffer. It only seems to write 1024 * n + 1 bytes ignoring the other bytes. This happens only on an AIX machine. The same code works fine in Windows.

Here are a few runs with different values for size:

For the first run, the size is 1024 bytes , but only 1 byte is written to the file "test". If the size is between 1025 and 2048, only the first 1025 bytes are written to "test" and so on.

Anyone have any idea as to what is happening here?
 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I try your code on Windows the file size is correct each time. Possibly the flushing does not work well. What happens if you call force() on the MappedByteBuffer?
 
Satish Chilukuri
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:When I try your code on Windows the file size is correct each time. Possibly the flushing does not work well. What happens if you call force() on the MappedByteBuffer?


It works in Windows for me too. The problem is in AIX.

I tried calling force() after put(), but the results stay the same.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!