Overwriting txt file in java
问题 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=new File("../playlist/"+existingPlaylist.getText()+".txt"); String source = textArea.getText(); System.out.println(source); FileWriter f2; try { f2 = new FileWriter(fnew,false); f2.write(source); /*for (int i=0; i<source.length();i++) { if(source.charAt(i)=='\n') f2.append(System.getProperty("line.separator")); f2.append(source.charAt(i));