Example usage for java.util.logging ErrorManager OPEN_FAILURE

List of usage examples for java.util.logging ErrorManager OPEN_FAILURE

Introduction

In this page you can find the example usage for java.util.logging ErrorManager OPEN_FAILURE.

Prototype

int OPEN_FAILURE

To view the source code for java.util.logging ErrorManager OPEN_FAILURE.

Click Source Link

Document

OPEN_FAILURE is used when an open of an output stream fails.

Usage

From source file:FileErrorManager.java

/**
 * Performs the initialization for this object.
 *//*from   w w w. j a  v a2  s.c  o  m*/
private void init() {
    if (next == null) {
        throw new NullPointerException(ErrorManager.class.getName());
    }

    File dir = this.emailStore;
    if (dir.getClass() != File.class) { //For security reasons.
        throw new IllegalArgumentException(dir.getClass().getName());
    }

    if (!dir.isDirectory()) {
        throw new IllegalArgumentException("File must be a directory.");
    }

    if (!dir.canWrite()) { //Can throw under a security manager.
        super.error(dir.getAbsolutePath(), new SecurityException("write"), ErrorManager.OPEN_FAILURE);
    }

    //For now, only absolute paths are allowed.
    if (!dir.isAbsolute()) {
        throw new IllegalArgumentException("Only absolute paths are allowed.");
    }

    if (!dir.canRead()) { //Can throw under a security manager.
        super.error(dir.getAbsolutePath(), new SecurityException("read"), ErrorManager.OPEN_FAILURE);
    }
}