• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

[Java NIO] MappedByteBuffer does not write all bytes

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic