java - How can I write from the ArrayList to file, each element from the ArraList in a new line? -


What I wanted to do was to convert an ArrayList to a file and after that, use the file line per line.

My code:

  list & lt; String & gt; Inserts = New Arrestists & lt; String & gt; (); String file toggle = null; . . . . FileToLoad = prpfile.properties (); Println (FileToLoad); Flemwriter Writer = New Flamewriter (File Transfer); For (string s: inserts) {author.write (str); } Author. Close (); String Query NewData = "Load Data Local INFILE" "+ File Tallod +" Table 'defined in the field of companies designated', '(name, address, number u, post, status) "; UpdateDatabase LoadNewData = New update database (); LoadNewData .LoadQuery (QueryNewData);   

Runs the code, the file is created properly but it is created wholw ArrayLIST in a single row How to bring a new row for each element in ArrayList ?

There are obvious things that c

  • Streaming did not stop
  • You should remember that a simple author does not magically engage the line feed, you can print it in printstrik, which has a printline (like) System.out or you Answer as a response (i.e.) manually add a line feed.

    However, I can suggest this for reasons of cross-platform The front:

      writer.write (str + System.getProperty ( "line. Separator "));    

  • Comments

    Popular posts from this blog

    c - Mpirun hangs when mpi send and recieve is put in a loop -

    python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

    java - Unable to get JDBC connection in Spring application to MySQL -