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.