You should use the FileStatus API to access file metadata. See below a example.
http://hadoop.apache.org/common/docs/current/api/org/apache/hadoop/fs/FileSt atus.html Configuration conf = new Configuration(); // takes default conf FileSystem fs = FileSystem.get(conf); Path dir = new Path("/dir"); FileStatus[] stats = fs.listStatus(dir); foreach(FileStatus stat : stats) { stat.getPath().toUri().getPath(); // gives directory name stat.getModificationTime(); stat.getReplication(); stat.getBlockSize(); stat.getOwner(); stat.getGroup(); stat.getPermission().toString(); } > From: Denim Live <[email protected]> > Date: Wed, 25 Aug 2010 07:36:11 +0000 (GMT) > To: <[email protected]> > Subject: How to enumerate files in the directories? > > Hello, how can one determine the names of the files in a particular hadoop > directory, programmatically? iCrossing Privileged and Confidential Information This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information of iCrossing. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
