diskchecker.java

来自「hadoop:Nutch集群平台」· Java 代码 · 共 44 行

JAVA
44
字号
package org.apache.hadoop.util;import java.io.File;import java.io.IOException;/** * Class that provides utility functions for checking disk problem * @author Hairong Kuang */public class DiskChecker {    public static class DiskErrorException extends IOException {      public DiskErrorException(String msg) {        super(msg);      }    }        public static class DiskOutOfSpaceException extends IOException {        public DiskOutOfSpaceException(String msg) {          super(msg);        }      }          public static void checkDir( File dir ) throws DiskErrorException {        if( !dir.exists() && !dir.mkdirs() )            throw new DiskErrorException( "can not create directory: "                     + dir.toString() );                if ( !dir.isDirectory() )            throw new DiskErrorException( "not a directory: "                     + dir.toString() );                    if( !dir.canRead() )            throw new DiskErrorException( "directory is not readable: "                     + dir.toString() );                    if( !dir.canWrite() )            throw new DiskErrorException( "directory is not writable: "                     + dir.toString() );    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?