Java: PrintWriter

后端 未结 1 384
盖世英雄少女心
盖世英雄少女心 2021-01-28 00:12

I am trying to use PrintWriter.java but I am getting a rather strange problem and I am not able to figure out what am I am missing here.

MyPrint

1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-28 00:21

    You probably need to flush your print writer.

    The PrintWriter constructor with a FileWriter parameter creates a PrintWriter with autoFlush set to off

    Calling pw.flush() before pw.close(); should do the trick

    0 讨论(0)
提交回复
热议问题