Java reads how the contents of the file are displayed on one line

reads its contents from a .txt, with similar information in the text as follows:
Info 1
Info 2
Info 3
.
the code I wrote is
public class FileMessage {

public static void main(String[] args) throws Exception {
    File file  = new File("D:"+File.separator+"test.txt");
    if(!file.exists()){
        throw new Exception("");
    }
    InputStream is = new FileInputStream(file);
    byte[] byt = new byte[(int)file.length()]; 
    is.read(byt);
    is.close();
    String result = new String(byt);
    result.replace("\r", "");
    result.replace("\n", "");
    System.out.println(":"+result);
}

}
the data read is always divided into multiple lines, but the requirements need to be displayed on one line. I would like to ask you why the replace () method does not work and remove the newline characters in the string. Or is there any other more elegant way to implement it?

Mar.16,2021

java.nio.file.Files this utility class has API, requirements for you that provide streaming text files:

Files.lines(Paths.get("D:", "test.txt")).collect(Collectors.joining());

java8


public class FileMessage2 {

public static void main(String[] args) throws Exception {
    File file  = new File("D:"+File.separator+"test.txt");
    if(!file.exists()){
        throw new Exception("");
    }

/ / InputStream is = new FileInputStream (file);
/ / byte [] byt = new byte [(int) file.length ()];
/ / is.read (byt);
/ / is.close ();
/ / String result = new String (byt);
/ / result.replace ("rn", ");

    
    FileReader fr = new FileReader(file);
    BufferedReader br = new BufferedReader(fr);
    StringBuffer sb = new StringBuffer();
    String str;
    while((str=br.readLine())!=null){
        sb.append(str);
    }
    br.close();
    fr.close();
    System.out.println(":"+sb);
}

}
uses a way to read by row, but I still don't know why the replace () method is invalid in the first writing, sad:-(

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b574-2c26a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b574-2c26a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?