Women in Technology

Hear us Roar



Article:
  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().
Full Threads Newest 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();
    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);
    }
    }
    }