How to remove all blank spaces and empty lines from a txt File using Java SE?
Input:
qwe qweqwe qwe qwe
Output:
... Scanner scanner = new Scanner(new File("infile.txt")); PrintStream out = new PrintStream(new File("outfile.txt")); while(scanner.hasNextLine()){ String line = scanner.nextLine(); line = line.trim(); if(line.length() > 0) out.println(line); } ...