Reading and writing from and to the same file in Java

后端 未结 3 890
情话喂你
情话喂你 2021-02-20 03:58

I want to read from criteria.txt file, to tokenize and append at the end of the same file the tokens. The program throws an exception: No file found!

3条回答
  •  故里飘歌
    2021-02-20 04:34

    In my opinion you can't do that. You can't open the same file to read and write at the same time. You have to open and save the file information in a data structure and then close it. Then you have to work with the data structure in memory and open the file to write results. And when you finish to write you should close it.

提交回复
热议问题