As given in JAVA docs, the variable 'trouble' gets set to true whenever there is a java.io.IOException. I write a program:
import java.io.*;
class First
{
public static void main(String[] args) throws Exception
{
File f = new File("a.txt");
PrintStream ps = new PrintStream(f);
f.delete();
ps.write(65);
boolean b = ps.checkError();
System.out.println(b); //Output: false
ps.close();
}
}
Even if I deleted the file before writing, why the method checkError() is not returning true? Please give an example when the variable 'trouble' set to true and the method checkError() returns true.