• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing byte[ ] to a file  RSS feed

 
roy williams
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, i am having problems. I am reading bytes from a queue(mq series) and trying to simply write the bytes out to a .dat file, it is creating the file but it is empty. I'm not to good at Java IO so I need help - what am i doing wrong??
thanks , here is the code:
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that your array b has any elements? Why don't you try printing out the contents of the array via println() or the length immeiately after you have called message.readFully(b);
Also, try flushing the cache before you call message.clearMessage()
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, are you sure the file is really empty? It's possible that it's filled with NULL chars (value 0) and you're looking at it with a viewer that makes it look like nothing's there. Double-check the size of the file, as well as the array size as Rob suggests.
Also as suggested by Barry in another thread, call bos.close() at the end. (The flush() call should have the same basic effect for our purposes, but maybe not...)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!