How do I remove some String from file - but not all of them JAVA : Here's the problem. I have some text in my .txt file, it look exactly like this:

    Bee-bee is the voice that Sheep giv-
    e. Mou-Mou is the voice that Cow gi-
    ve. Miau-Miau is the voice that Ca-
    t gives.

Program that I need reading this file and connect line. Output (txt.file):

    Bee-bee is the voice that Sheep give. Mou-Mou is the voice that Cow give. Miau-Miau is the voice that Cat gives.

I think I need to do something like this:

    //Locate the file:
    File file = new File("/path/to/file.txt");
    
    //Create a temporary file
    File temp = File.createTempFile("file", ".txt", file.getParentFile());
    
    //String I want to remove
    String delete = "-";
    
    //open the file, open the tmp file, read the file line by line and replacing signs
    
    for (String line; (line = reader.readLine()) != null;) {
        // ...
    }
    Delete the string from the line.
    
        line = line.replace(delete, "");

Here's a problem that it replace "Bee-bee" with "beebee" in output file and that is not what I want. I need some construction "if the sign is "-" and the next sign is carriage return, delete "-"" but I have no idea how to write this.