So my code looks like this:
try { while ((line = br.readLine()) != null) { Matcher m = urlPattern.matcher (line); while (m.find()) { System.out.println(m.group(1)); //the println puts linebreak after each find String filename= "page.txt"; FileWriter fw = new FileWriter(filename,true); fw.write(m.group(1)); fw.close(); //the fw writes everything after each find with no line break } }
I get the correct output form in the line System.out.println(m.group(1)); However, when I later want to write what is shown m.group(1) It writes to a file without placing a line, since the code does not have this.
source share