java - Insert line break when writing to file? -


so code looks 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 after each find no line break     } } 

i right form of output @ line system.out.println(m.group(1)); when later on want write shown m.group(1) writes file without putting linebreak since code doesn't have one.

just call fw.write(system.getproperty("line.separator"));.

system.getproperty("line.separator") give line separator platform (whether windows or unix flavor).


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -