PrintStream Only Printing out the Last Line of Input File

后端 未结 2 1750
星月不相逢
星月不相逢 2021-01-29 07:34

I have this code

public class program {
    public static void main(String[] args) {
        try {
            String filePath = (args[0]);
            String st         


        
2条回答
  •  [愿得一人]
    2021-01-29 08:34

    Because you are overwriting to the same file within the loop. Create the PrintStream outside of the loop not inside the loop and it should write all lines!

提交回复
热议问题