It should be doable like this:

FileSystem.getContentSummary(FileStatus.getPath()).getLength();

On Thu, Oct 21, 2010 at 1:47 AM, Ananth Sarathy
<ananth.t.sara...@gmail.com> wrote:
> I am trying to see how what the total size of all the files within a
> directory  in HDFS is. I try
>
> Configuration conf = new Configuration();
>
>            Path inFile = new Path(
>                    "/MyDir");
>
>            FileSystem fs = inFile.getFileSystem(conf);
>
>
>            FileStatus status = fs.getFileStatus(inFile);
>
>            System.out.println(status.isDir());
>            System.out.println(status.getLen());
>
>
> But since it's a directory, i get a 0. Anyone have any idea on how I can get
> this info? I am using apache hadoop 20.2.
>
> Secondly, I assume FileSystem.getUsed and FileStatus.getLen is in bytes,
> correct?
>
> Ananth T Sarathy
>



-- 
Harsh J
www.harshj.com

Reply via email to