Write your own code to an empty line

 

import java.io. * ;

public class RemoveEmp3{
    public static void readwrite(String filePath)throws IOException{
        FileInputStream finput = new FileInputStream(filePath);
        InputStreamReader isr = new InputStreamReader(finput);
        BufferedReader br = new BufferedReader(isr);
        
        File file = new File("new.java");
        if(!file.exists()){
            file.createNewFile();
        }
        FileOutputStream fos = new FileOutputStream(file);
 
    OutputStreamWriter osw = new OutputStreamWriter(fos);
        
        for (String Line br.readLine = ();! Line = null ; Line = br.readLine ()) {
             IF (line.matches ( "^ [S \\ && [^ \\ n-]] * $" )) { the escape character // blank line
                ;
            }
            else{
                osw.write(line+"\n");
                System.out.println(line);
            }
        }
        br.close();
        osw.close ();
        
    }
    public static void main(String[] args){
        Str1 String = "E: / A Course learning materials / software configurations Dan / software configuration / code to the blank line is (write your own) /RemoveEmp2.java" ;
         the try {
            readwrite(str1);
        }catch(IOException e){
            ;
        }
    }
}

Escape character blank lines: ^ [\\ s && [^ \\ n]] * $

Guess you like

Origin www.cnblogs.com/jmdd/p/12113220.html