I am encountering erroneous results while trying to encode and decode a string read from a file on disk.
I am using the following code to decode and then encode :
byte[] word_bytes = new BASE64Decoder().decodeBuffer(word); //word is string variable
String tempStr = new BASE64Encoder().encode(word_bytes);
On the basis of this code, I was expecting that if I print "word" and "tempStr", I should see the same result. However, the values are different.
For example, if word = "hi!", then tempStr = "hi//" and all single letter words get converted to null values. For example, if word = "a", then tempStr = "".
The file on disk is in UTF-8 encoding.
It would be very helpful if someone can explain the cause of this error.
sorry if this is very basic question, I don't have much prior experience with encoding formats.
Thanks