Writing a string array to file using Java - separate lines

前端 未结 5 673
不知归路
不知归路 2020-12-12 07:06

I\'m writing a program that writes sets of observations in the form of a String array (from User input) to file. I am able to write an observation to a .txt file and then ad

5条回答
  •  醉话见心
    2020-12-12 07:39

    Why not iterate within your try{} block and use BufferedWriter.newLine() after each write ?

    If you need to be able to read the values back in later, you need to consider some unambiguous output format. Perhaps the simplest solution is a CSV format (I note your output data has spaces - you would need to separate your entries using something other than spaces in that case)

提交回复
热议问题