1

I want to convert a series of bytes in a byte[] to a string to append to a text file. Then when the string is pulled I want to convert it back to byte[] to decode it. I know I can't use getBytes(), I need to copy the string to it's original byte[] format then decode it back to a readable string. Is this possible?

     byte[] hash = pw.getBytes("UTF8");
     pw = hash.toString();

Then I pass the string to another class where I need it to be read as bytes, not changed to its byte form.

Roman C
  • 49,761
  • 33
  • 66
  • 176
caine1337
  • 63
  • 1
  • 7

1 Answers1

3

toString won't work. You need to write, because that is the string representation of Array Object.

String s = new String(hash,"UTF-8");
Roman C
  • 49,761
  • 33
  • 66
  • 176
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307