Forums Register Login

Writing byte[ ] to a file

+Pie Number of slices to send: Send
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:
+Pie Number of slices to send: Send
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()
+Pie Number of slices to send: Send
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...)
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1178 times.
Similar Threads
File Transfer via Sockets
Cannot Figure Out This Syntax Error
write array of bytes to a file
write byte array to a file
how to append to word doc files
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 21:15:22.