Use of filestatue in HDFS

Source: Internet
Author: User
// CC liststatus shows the file statuses for a collection of paths in a hadoop filesystem/** one path generates one or more filestatuses, each file and directory will generate a */import java.net. uri; import Org. apache. hadoop. conf. configuration; import Org. apache. hadoop. FS. filestatus; import Org. apache. hadoop. FS. filesystem; import Org. apache. hadoop. FS. fileutil; import Org. apache. hadoop. FS. path; // VV liststatuspublic class liststatus {public static void main (string [] ARGs) throws exception {string uri = ARGs [0]; configuration conf = new configuration (); filesystem FS = filesystem. get (URI. create (URI), conf); // obtain the file system // obtain the path array path [] paths = new path [args. length]; for (INT I = 0; I <paths. length; I ++) {paths [I] = New Path (ARGs [I]);} system. out. println ("Path's number =" + paths. length); // output the number of original paths. filestatus [] status = FS. liststatus (paths); // generate filestatus system by path. out. println ("filestatue's number =" + status. length); // output the number of filestatus generated by the number of original paths for (filestatus SS: Status) // The owner is the user who creates this directory or files {system. out. println (ss. getowner ();} path [] listedpaths = fileutil. stat2paths (Status); // convert the file information and directory information in each statue to the path for (path P: listedpaths) {// output path system. out. println (p) ;}}// ^ liststatus

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.