After the byte stream is converted into a string, why is the file after the string is converted into a byte stream different?

  java, question
public static void main(String[] args) throws Exception {
 Filesourcefile = newfile ("/home/joy/picture /img1-lg.jpg");
 Filetempfile = newfile ("/home/joy/desktop /TempFile");
 saveTempFile(sourceFile, tempFile);
 String str = byteToString(tempFile);
 Filesavefile = newfile ("/home/joy/desktop /saveFile.jpg");
 StringTobyte(str,saveFile);
 bracket
 
 //Save temporary files
 public static void saveTempFile(File sourceFile, File tempFile) throws Exception {
 FileInputStream inputStream = new FileInputStream(sourceFile);
 FileOutputStream fileOutputStream = new FileOutputStream(tempFile);
 byte[] buf = new byte[10 * 1024];
 int readLeng = 0;
 while ((readLeng = inputStream.read(buf)) !  = -1) {
 fileOutputStream.write(buf, 0, readLeng);
 fileOutputStream.flush();
 bracket
 fileOutputStream.close();
 inputStream.close();
 bracket
 
 //File Bytes to String
 public static String byteToString(File file) throws Exception {
 StringBuilder returnDatas = new StringBuilder();
 FileInputStream fileInputStream = new FileInputStream(file);
 byte[] buf = new byte[10 * 1024];
 int readLenth = 0;
 while ((readLenth = fileInputStream.read(buf)) !  = -1) {
 returnDatas.append(new String(buf,0,readLenth));
 bracket
 fileInputStream.close();
 return returnDatas.toString();
 bracket
 
 //String to File
 public static void StringTobyte(String str,File file) throws Exception {
 FileOutputStream fileOutputStream = new FileOutputStream(file);
 fileOutputStream.write(str.getBytes());
 fileOutputStream.close();
 bracket

The main idea of the code is to convert a picture into a character string through byte stream, and then restore it to a file after obtaining the byte of the character string.
In understanding, characters are only encoded with one more layer, and source files should still be available after being restored to bytes.

while ((readLenth = fileInputStream.read(buf)) !  = -1) {
 returnDatas.append(new String(buf,0,readLenth));
 bracket

The binary pictures file read is not a legal string, and the unresolved binary data will be filtered out.
ReferencesjavadocDescription in:

This method always replaces malformed-input and unmappable-character sequences with this charset’s default replacement string.