Answers for "printwriter java append to file"

0

printwriter java append to file

public static void usingPrintWriter() throws IOException 
{
    String textToAppend = "Happy Learning !!";
     
    FileWriter fileWriter = new FileWriter("c:/temp/samplefile.txt", true); //Set true for append mode
    PrintWriter printWriter = new PrintWriter(fileWriter);
    printWriter.println(textToAppend);  //New line
    printWriter.close();
}
Posted by: Guest on December-12-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language