Women in Technology

Hear us Roar

  Surviving Abrupt Shutdown
Subject:   SwingApps not failing
Date:   2008-02-15 04:17:19
From:   LeapFrog
The SwingApps codes above do not produce any errors becuase you need to check the return value on file.createNewFile().
Main Topics Oldest First

Showing messages 1 through 1 of 1.

  • SwingApps not failing
    2008-02-15 04:25:25  LeapFrog [View]

    The code below should work as announced:

    private void initialize() {
    // add shutdown hook
    final MyShutdownHook shutdownHook = new MyShutdownHook();
    final File file = new File(dir, filename);

    try {
    System.out.println("Creating temporary file: ");
    try {
    if (! file.createNewFile()) throw new IOException();
    } catch (final IOException e) {
    System.out.println("Failed creating temporary file.");