hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob R Rideout <apa...@jacobrideout.net>
Subject Re: Accessing HDFS
Date Fri, 07 Jan 2011 21:55:23 GMT
>  I'm wondering if there is a way to doing the following commands to  HDFS  ...
>   File LocalinputDir = new File ("/user/maha/inputDir");
>   String[] file = LocalinputDir.list();
> I'm given Hadoop and input directory with files {f1,f2 ..}. I would like for hadoop to
open the directory and list the file names .. how can I do that?
> or  I know I can copyToLocal the directory and use the regular-local fs.List() to see
the file names . But the other way is faster,

You could do something like:

Path f = new Path("hdfs://user/maha/inputDir");
FileSystem fs = f.getFileSystem(new Configuration());
for(FileStatus s : fs.listStatus(f)) {

Software Engineer
Return Path, Inc
Skype:   jrideout
Twitter: @jrideout

View raw message