java writing to a text file

后端 未结 6 1043
梦毁少年i
梦毁少年i 2020-12-17 21:07

I would like the following to be printed

test1

test2

test3

test4

But I can\'t seem to get the text to the next line.

Plea

6条回答
  •  情深已故
    2020-12-17 22:03

    Try out.newLine();

    So, it would be

    for (int i = 0; i < 4; i++) {
        out.write("test " + "\n");
        out.newLine();
    }
    

    Source (Java API)

提交回复
热议问题