NB: thread heading is littele bit wrong, I want to exclude lines from writing to output which start with specific character
human
donkey
monkery
I want to write human and monkey, and exclude line which starts with "d"-donkey.
Is there built in method or smthng to say to write from file to another file lines that do not start with defined charachter so i can enter that character into parameters or..?
try { File input = new File("input"); File output = new File("output"); Scanner sc = new Scanner(input); PrintWriter printer = new PrintWriter(output); while (sc.hasNextLine()) { String s = sc.nextLine(); printer.write(s); } printer.flush(); } catch (FileNotFoundException e) { System.err.println("File not found. Please scan in new file."); }