hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pratyush Banerjee <pratyushbaner...@aol.com>
Subject Re: About HDFS` class Path
Date Mon, 28 Jul 2008 12:41:29 GMT

The  listPaths API has been depricated for sometime now. So you can use 
the following API's for the purpose.

**org.apache.hadoop.fs.FileSystem.listStatus(org.apache.hadoop.fs.Path f)

the details of the listStatus API is 

**public abstract FileStatus <http://hadoop.apache.org/core/docs/current/api/org/apache/hadoop/fs/FileStatus.html>[]
*listStatus*(Path <http://hadoop.apache.org/core/docs/current/api/org/apache/hadoop/fs/Path.html>
                                 throws IOException <http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html>

    List the statuses of the files/directories in the given path if the
    path is a directory.

        |f| - given path 
        the statuses of the files/directories in the given patch 

Also org.apache.hadoop.fs.FileSystem class gives you a method called 
isFile(Path p)

public boolean *isFile*(Path <http://hadoop.apache.org/core/docs/current/api/org/apache/hadoop/fs/Path.html>
               throws IOException <http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html>

    True iff the named path is a regular file.


Finally org.apache.hadoop.fs.FileStatus will give you a isDir() function

public boolean *isDir*()

    Is this a directory?

        true if this is a directory

Hope these APIs help you in your purpose.


wangxiaowei wrote:
> Thank you ! But could you point out which class the function listPaths belongs to.I can
not find it in Path ,FileStatus and FileSystem in hadoop-0.17.1.
> ----- Original Message ----- 
> From: "Andreas Kostyrka" <andreas@kostyrka.org>
> To: <core-user@hadoop.apache.org>
> Sent: Monday, July 28, 2008 7:37 PM
> Subject: Re: About HDFS` class Path

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message