Hear us Roar
Article:
 |
|
Surviving Abrupt Shutdown
|
| Subject: |
|
SwingApps not failing |
| Date: |
|
2008-02-15 04:25:25 |
| From: |
|
LeapFrog
|
Response to: SwingApps not failing
|
|
The code below should work as announced:
private void initialize() {
// add shutdown hook
final MyShutdownHook shutdownHook = new MyShutdownHook();
Runtime.getRuntime().addShutdownHook(shutdownHook);
final File file = new File(dir, filename);
try {
System.out.println("Creating temporary file: ");
System.out.println(dir);
System.out.println(filename);
try {
if (! file.createNewFile()) throw new IOException();
} catch (final IOException e) {
System.out.println("Failed creating temporary file.");
System.exit(1);
}
}
}
|
|
| |