how to delete the content of text file without deleting itself

前端 未结 17 1299
逝去的感伤
逝去的感伤 2020-11-28 03:05

I want to copy the content of file \'A\' to file \'B\'. after the copying is done I want to clear the content of file \'A\' and want to write on it from its beginning. I can

17条回答
  •  鱼传尺愫
    2020-11-28 04:11

    One of the best companion for java is Apache Projects and please do refer to it. For file related operation you can refer to the Commons IO project.

    The Below one line code will help us to make the file empty.

    FileUtils.write(new File("/your/file/path"), "")
    

提交回复
热议问题