try{
    File file = new File("write.txt");
    FileWriter writer = new FileWriter(file);
    PrintWriter printWriter = new PrintWriter(writer);
    printWriter.println("pqr");
    printWriter.println("jkl");
    printWriter.close();
    PrintWriter printWriter = new PrintWriter(file);
    printWriter.println("abc");
    printWriter.println("xyz");
    printWriter.close();
}
I don't understand what is difference bet'n these two way. In which scenario i should use printWriter and fileWriter.
 
     
     
     
     
    