Java API access to Hadoop's HDFs file system without Filesystem.get (Uri.create ("Hdfs://.......:9000/"), conf) __java

Source: Internet
Author: User
Import Java.net.URI;  
  
Import org.apache.hadoop.conf.Configuration;  
Import Org.apache.hadoop.fs.FileSystem;  
Import Org.apache.hadoop.fs.Path;  
  
public class Hdfsrename  
{public  
    static void Main (string[] args) throws Exception  
    {  
        Configuration conf = New Configuration ();  

FileSystem HDFs = filesystem.get (conf);  
 FileSystem HDFs = Filesystem.get (Uri.create ("Hdfs://192.168.80.10:9000/"), conf);  
          
        Path src = new Path ("/test.txt");  
          
        Path DST = new Path ("/test2.txt");  
          
        Boolean isrenamed = Hdfs.rename (SRC,DST);  
          
        System.out.println (isrenamed);  
          
    }  
  

Here is a section of the Java API to access the HDFs file system code, the code is very short, but the author has stumbled here.

Note that the following line of code, if changed to the code in the annotation, then hdfs that is certainly inaccessible,

His teacher will report a mistake that doesn't exist in the document.

In fact, access to the HDFS system is not available.


It would make a mistake like this,


Just like the writer was puzzled before, the document exists clearly, but it says file not exist.

Related Article

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.