⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filesystem.java

📁 hadoop:Nutch集群平台
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     */    public abstract FSOutputStream createRaw(Path f, boolean overwrite,                                              short replication,                                             long blockSize)      throws IOException;    /** Opens an OutputStream at the indicated Path with write-progress     * reporting.     * @param f the file name to open     * @param overwrite if a file with this name already exists, then if true,     *   the file will be overwritten, and if false an error will be thrown.     * @param replication required block replication for the file.      */    public abstract FSOutputStream createRaw(Path f, boolean overwrite,                                              short replication,                                             long blockSize, Progressable progress)      throws IOException;        /** @deprecated Call {@link #createNewFile(Path)} instead. */    public boolean createNewFile(File f) throws IOException {      return createNewFile(new Path(f.toString()));    }    /**     * Creates the given Path as a brand-new zero-length file.  If     * create fails, or if it already existed, return false.     */    public boolean createNewFile(Path f) throws IOException {        if (exists(f)) {            return false;        } else {          create(f,false,getConf().getInt("io.file.buffer.size", 4096)).close();          return true;        }    }    /**     * Set replication for an existing file.     *      * @param src file name     * @param replication new replication     * @throws IOException     * @return true if successful;     *         false if file does not exist or is a directory     */    public boolean setReplication(Path src, short replication) throws IOException {      boolean value = setReplicationRaw(src, replication);      if( ! value )        return false;      Path checkFile = getChecksumFile(src);      if (exists(checkFile))        setReplicationRaw(checkFile, replication);      return true;    }    /**     * Get replication.     *      * @param src file name     * @return file replication     * @throws IOException     */    public abstract short getReplication(Path src) throws IOException;    /**     * Set replication for an existing file.     *      * @param src file name     * @param replication new replication     * @throws IOException     * @return true if successful;     *         false if file does not exist or is a directory     */    public abstract boolean setReplicationRaw(Path src, short replication) throws IOException;    /** @deprecated Call {@link #rename(Path, Path)} instead. */    public boolean rename(File src, File dst) throws IOException {      return rename(new Path(src.toString()), new Path(dst.toString()));    }    /**     * Renames Path src to Path dst.  Can take place on local fs     * or remote DFS.     */    public boolean rename(Path src, Path dst) throws IOException {      if (isDirectory(src)) {        return renameRaw(src, dst);      } else {        boolean value = renameRaw(src, dst);        if (!value)          return false;        Path checkFile = getChecksumFile(src);        if (exists(checkFile)) { //try to rename checksum          if(isDirectory(dst)) {            renameRaw(checkFile, dst);          } else {            renameRaw(checkFile, getChecksumFile(dst));           }        }        return value;      }          }    /**     * Renames Path src to Path dst.  Can take place on local fs     * or remote DFS.     */    public abstract boolean renameRaw(Path src, Path dst) throws IOException;    /** @deprecated Call {@link #delete(Path)} instead. */    public boolean delete(File f) throws IOException {      return delete(new Path(f.toString()));    }    /** Delete a file. */    public boolean delete(Path f) throws IOException {      if (isDirectory(f)) {        return deleteRaw(f);      } else {        deleteRaw(getChecksumFile(f));            // try to delete checksum        return deleteRaw(f);      }    }    /**     * Deletes Path     */    public abstract boolean deleteRaw(Path f) throws IOException;    /** @deprecated call {@link #exists(Path)} instead */    public boolean exists(File f) throws IOException {      return exists(new Path(f.toString()));    }    /** Check if exists. */    public abstract boolean exists(Path f) throws IOException;    /** @deprecated Call {@link #isDirectory(Path)} instead. */    public boolean isDirectory(File f) throws IOException {      return isDirectory(new Path(f.toString()));    }    /** True iff the named path is a directory. */    public abstract boolean isDirectory(Path f) throws IOException;    /** @deprecated Call {@link #isFile(Path)} instead. */    public boolean isFile(File f) throws IOException {      return isFile(new Path(f.toString()));    }    /** True iff the named path is a regular file. */    public boolean isFile(Path f) throws IOException {        if (exists(f) && ! isDirectory(f)) {            return true;        } else {            return false;        }    }        /** @deprecated Call {@link #getLength(Path)} instead. */    public long getLength(File f) throws IOException {      return getLength(new Path(f.toString()));    }    /** The number of bytes in a file. */    public abstract long getLength(Path f) throws IOException;    /** @deprecated Call {@link #listPaths(Path)} instead. */    public File[] listFiles(File f) throws IOException {      Path[] paths = listPaths(new Path(f.toString()));      if (paths == null)        return null;      File[] result = new File[paths.length];      for (int i = 0 ; i < paths.length; i++) {        result[i] = new File(paths[i].toString());      }      return result;    }    final private static PathFilter DEFAULT_FILTER = new PathFilter() {      public boolean accept(Path file) {        return !isChecksumFile(file);      }         };      /** List files in a directory. */    public Path[] listPaths(Path f) throws IOException {      return listPaths(f, DEFAULT_FILTER);    }        /** List files in a directory. */    public abstract Path[] listPathsRaw(Path f) throws IOException;    /** @deprecated Call {@link #listPaths(Path)} instead. */    public File[] listFiles(File f, final FileFilter filt) throws IOException {      Path[] paths = listPaths(new Path(f.toString()),                               new PathFilter() {                                 public boolean accept(Path p) {                                   return filt.accept(new File(p.toString()));                                 }                               });      if (paths == null)        return null;      File[] result = new File[paths.length];      for (int i = 0 ; i < paths.length; i++) {        result[i] = new File(paths[i].toString());      }      return result;    }        /** Filter raw files in a directory. */    private void listPaths(ArrayList<Path> results, Path f, PathFilter filter)      throws IOException {      Path listing[] = listPathsRaw(f);      if (listing != null) {        for (int i = 0; i < listing.length; i++) {          if (filter.accept(listing[i])) {            results.add(listing[i]);          }        }      }          }        /** Filter raw files in a directory. */    public Path[] listPaths(Path f, PathFilter filter) throws IOException {        ArrayList<Path> results = new ArrayList<Path>();        listPaths(results, f, filter);        return (Path[]) results.toArray(new Path[results.size()]);    }    /**      * Filter raw files in a list directories using the default checksum filter.      * @param files: a list of paths     * @return a list of files under the source paths     * @exception IOException     */    public Path[] listPaths(Path[] files ) throws IOException {      return listPaths( files, DEFAULT_FILTER );    }        /**      * Filter raw files in a list directories using user-supplied path filter.      * @param files: a list of paths     * @return a list of files under the source paths     * @exception IOException     */    public Path[] listPaths(Path[] files, PathFilter filter)    throws IOException {      ArrayList<Path> results = new ArrayList<Path>();      for(int i=0; i<files.length; i++) {        listPaths(results, files[i], filter);      }      return (Path[]) results.toArray(new Path[results.size()]);    }        /**     * <p>Return all the files that match filePattern and are not checksum     * files. Results are sorted by their names.     *      * <p>     * A filename pattern is composed of <i>regular</i> characters and     * <i>special pattern matching</i> characters, which are:     *     * <dl>     *  <dd>     *   <dl>     *    <p>     *    <dt> <tt> ? </tt>     *    <dd> Matches any single character.     *     *    <p>     *    <dt> <tt> * </tt>     *    <dd> Matches zero or more characters.     *     *    <p>     *    <dt> <tt> [<i>abc</i>] </tt>     *    <dd> Matches a single character from character set     *     <tt>{<i>a,b,c</i>}</tt>.     *     *    <p>     *    <dt> <tt> [<i>a</i>-<i>b</i>] </tt>     *    <dd> Matches a single character from the character range     *     <tt>{<i>a...b</i>}</tt>.  Note that character <tt><i>a</i></tt> must be     *     lexicographically less than or equal to character <tt><i>b</i></tt>.     *     *    <p>     *    <dt> <tt> [^<i>a</i>] </tt>     *    <dd> Matches a single character that is not from character set or range     *     <tt>{<i>a</i>}</tt>.  Note that the <tt>^</tt> character must occur     *     immediately to the right of the opening bracket.     *     *    <p>     *    <dt> <tt> \<i>c</i> </tt>

⌨️ 快捷键说明

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