I have converted a string into byte in java and stored that byte data into a string variable.
String s = "anu";
byte[] d = s.getBytes();
String e = Arrays.toString(d);
How can I convert that string (in this case variable 'e') again into the same string assigned to s i.e."anu";
Firstly, I'd strongly advise against using getBytes()
without a charset parameter.
Next, just use the string constructor that takes a byte array and a charset:
String s = "anu";
byte[] d = s.getBytes(StandardCharsets.UTF_8);
String e = new String(d, StandardCharsets.UTF_8);
Note that you should only do this for data which is inherently text to start with. If you've actually started with arbitrary binary data (e.g. an image, or the result of compression or encryption) you should use base64 or hex to represent it in text, otherwise you're very likely to lose data.
See more on this question at Stackoverflow