In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Import java.io.ByteArrayOutputStream
Import java.io.InputStream
Import java.net.URL
Import org.apache.hadoop.conf.Configuration
Import org.apache.hadoop.fs.FSDataInputStream
Import org.apache.hadoop.fs.FileStatus
Import org.apache.hadoop.fs.FileSystem
Import org.apache.hadoop.fs.FsUrlStreamHandlerFactory
Import org.apache.hadoop.fs.LocalFileSystem
Import org.apache.hadoop.fs.Path
Import org.apache.hadoop.io.IOUtils
Import org.junit.Test
/ * *
* Test the API of the hadoop file system
*
* @ author Administrator
*
, /
Public class localfilesytem {
/ * *
* get the local file system through the filesystem object API
*
* @ author Administrator
*
*
*
*
, /
@ Test
Public void read () throws Exception {
/ / create configuration objects, which have a default loading order, starting from core-default.xml, and then to files in the src directory, which
/ / We have given
Configuration conf = new Configuration ()
/ / you can add the specified profile manually
/ / conf.addResource ("my-core-site.xml")
/ / the distributed file system fs is created through the configuration object of conf. By default, it is the local file system if no file is specified.
/ / system
FileSystem fs = FileSystem.get (conf)
/ / get the local file system object through the getLocal method
LocalFileSystem local = fs.getLocal (conf)
/ / get an array of file states through the listStatus method of the local file object
FileStatus [] arr = local.listStatus (new Path ("DRV /"))
/ / traversing the array
For (FileStatus fs0: arr) {
System.out.println (fs0.getPath ())
}
}
}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.