This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
perhaps there is something wrong with your definition of the reference variable to the File object fileTestOutput. Maybe it is pointing to a file that is read-only or to a directory that you don't have write access to?
I suggest that you post more of the exact error message that is being returned. Are you using a Java program to read the file that you have written? It is not clear from your post exactly what you are doing.
You might also want to take a look at the getBytes() method of the String class, which might help you do what you want more efficiently.
Yeah, well, how would I put it? The idea of putting binary data in a String is wrong. Remember that java Strings are not like char* in c. Java Strings are encoded in unicode, which means that after you make your conversion from bytearray to string, the byte on 86th position value of which was 231 is not a byte anymore and it's value does not have to be 231 anymore. And when you convert back to byte array, char value (which is in range 0-65535) is converted (casted in your case) to a byte value (0-255).
I wouldn't be surprised if something got lost... Do those 2 files have the same length? How about content?
Best regards, Petr
Get a better web browser:<br /><a href="http://www.mozilla.org/products/firefox/switch.html" target="_blank" rel="nofollow">http://www.mozilla.org/products/firefox/switch.html</a>