[Q#4141317][A#4141352] How to convert byte array into Human readable format?
https://stackoverflow.com/q/4141317
I am using "Blowfish" algorithm to encrypt and decrypt the contents of the text. I am embedding the encrypted contents in the image but while extracting I am getting the byte array which I am passing it to method update of class Cipher. But the method returns me byte array which I want to convert back into Human readable form. When I use write method of FileOutputStream it is working fine when a filename is provided. But now I want to print it on the console in the human readable format. How to get through this? I have tried for ByteArrayOutputStream too. But didn't work well. Thank you.
Answer
https://stackoverflow.com/a/4141352
APIzation
byte[] byteArray = new byte[] {87, 79, 87, 46, 46, 46};
String value = new String(byteArray);
package com.stackoverflow.api;
public class Human4141352 {
public static String readableByteArray(byte[] byteArray) {
return new String(byteArray);
}
}
package com.stackoverflow.api;
/**
* How to convert byte array into Human readable format?
*
* @author APIzator
* @see <a href="https://stackoverflow.com/a/4141352">https://stackoverflow.com/a/4141352</a>
*/
public class APIzator4141352 {
public static String convertArray(byte[] byteArray) throws Exception {
return new String(byteArray);
}
}