PrintWriter ppw = new PrintWriter( new PrintWriter(fw));
fw.close();
ppw.println("Hello World!");
file.deleteOnExit();
if (ppw.checkError()) {
System.out.println("Correct: An error occured in the" + " underlying writer");
passTest1 = true;
}
ppw.close();
// Test when the underlying stream is a PrintStream
FileOutputStream fos = new FileOutputStream(file);
PrintWriter pps = new PrintWriter( new PrintStream(fos));
fos.close();
pps.println("Hello World!");
if (pps.checkError()) {
System.out.println("Correct: An error occured in the" + " underlying Stream");
} else { if (!passTest1) { thrownew Exception("CheckError() returned an incorrect value" + " when error occured in the underlying Stream" + " and when error occured in the underlying writer");
} else { thrownew Exception("CheckError() returned an incorrect value" + " when the error has occured in the underlying Stream");
}
} if (!passTest1) { thrownew Exception("CheckError() returned an incorrect value" + " when the error has occured in the underlying Writer");
}
pps.close();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.