Today, nothing to do, so the basic operation of HDFs with Java to write a simplified program to give you some small help!
PackageCom.quanttech;Importorg.apache.hadoop.conf.Configuration;ImportOrg.apache.hadoop.fs.FileSystem;ImportOrg.apache.hadoop.fs.Path;/*** @topic HDFs file Operation Tool class *@authorZhouj **/ Public classHdfsutils {/** Determine if the HDFs directory exists path*/ Public Static BooleanIsexists (Configuration conf, String Path)throwsException {FileSystem fs=filesystem.get (conf); returnFs.exists (Newpath); } /** Remove a directory or file from HDFs*/ Public Static voidDelete (Configuration conf, String Path)throwsException {FileSystem fs=filesystem.get (conf); Fs.delete (NewPath (PATH),true); } /** Create an HDFs directory*/ Public Static voidMkdir (Configuration conf, String Path)throwsException {FileSystem fs=filesystem.get (conf); if(Fs.mkdirs (Newpath)) {System.out.println ("HDFs directory:" +path+ "created successfully! "); } }}
HDFs Java interface-simplifies HDFS file system operations