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
You can use
FileWriter fw = new FileWriter(/*your file path*/); PrintWriter pw = new PrintWriter(fw); pw.write(""); pw.flush(); pw.close();
Remember not to use
FileWriter fw = new FileWriter(/*your file path*/,true);
True in the filewriter constructor will enable append.