Java Reference
In-Depth Information
private void doSomeWork() throws IOException,
InterruptedException {
LinkedBlockingQueue<String> queue = new
LinkedBlockingQueue<>();
try {
FileOutputStream fos = new
FileOutputStream("out.log");
DataOutputStream dos = new
DataOutputStream(fos);
while (!queue.isEmpty()) {
dos.writeUTF(queue.take());
}
} catch (InterruptedException | IOException e ) {
e.printStackTrace();
throw e;
}
}
How It Works
It is possible to simply throw the exception that has been previously caught, and the
JVM will bubble the exception to the appropriate type. Note that you're if throwing a
checked exception, it must also be defined in the method declaration.
9-9. Logging Events Within Your Applic-
ation
Problem
You want to log events, debug messages, error conditions, and other events within your
application.
Search WWH ::




Custom Search