我创建了一个文件的字节数组。
FileInputStream fileInputStream=null;
File file = new File("/home/user/Desktop/myfile.pdf");
byte[] bFile = new byte[(int) file.length()];
try {
fileInputStream = new FileInputStream(file);
fileInputStream.read(bFile);
fileInputStream.close();
}catch(Exception e){
e.printStackTrace();
}
现在,我有一个 API,它需要一个 json 输入,我必须将上面的字节数组以字符串格式。在以字符串格式读取字节数组后,我需要再次将其转换回字节数组。所以,帮我找;
1)如何将字节数组转换为字符串,然后再转换回相同的字节数组?