Overwriting txt file in java

后端 未结 5 623
悲哀的现实
悲哀的现实 2020-12-17 08:10

The code I\'ve written is supposed to overwrite over the contents of the selected text file, but it\'s appending it. What am I doing wrong exactly?

File fnew         


        
5条回答
  •  不知归路
    2020-12-17 08:35

    Add one more line after initializing file object

    File fnew = new File("../playlist/" + existingPlaylist.getText() + ".txt");
    fnew.createNewFile();
    

提交回复
热议问题