code_junkie

How do you convert binary data to Strings and back in Java?

Nov 10th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. byte[] buffer = ...; // read from file
  2. // a few lines that prove I can process the data successfully
  3. String element = new String(buffer);
  4. byte[] newBuffer = element.getBytes();
  5. // a few lines that try to process newBuffer and fail because it is not the same data anymore
Add Comment
Please, Sign In to add comment