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.
Hi all, I have a byte array and I convert it to string during the execution of my program. After that, I have to convert the string to byte array again but when I compare the original byte array with the one that was converted by the string they are different. I'm using the "UTF8" encode to do all that. Here's a more precise explanation: I have this binary file and when I see its contents in linux I get the following result: ???IL ??I??4:?w? In my program I read this to a byte array and convert it to string as follows: byte block = new byte; FileInputStream rcfg_upt = new FileInputStream(upt); while(true) int bytesRead = rcfg_upt.read(block); // Copies file contents to block if (bytesRead == -1) break; String str = new String(block, "UTF8"); After that I copy the string str to a byte array: byte back = str.getBytes("UTF8"); Problem is when I print the new byte array or when I save it to an output file I get the following value: IL I 4: w a different value from the original. Is there a way to get this right? Thanks.