hdfs; org.apache.hadoop.conf.Configuration; org.apache.hadoop.fs.FileSystem; org.apache.hadoop.fs.Path; { main([] args) Exception{ Configuration conf Configuration(); FileSystem fsFileSystem.get(conf); fs.delete( Path(args[]), ); fs.close(); } }
hdfs; java.net.URI; org.apache.hadoop.conf.Configuration; org.apache.hadoop.fs.FSDataInputStream; org.apache.hadoop.fs.FileSystem; org.apache.hadoop.fs.Path; org.apache.hadoop.io.IOUtils; { main([] args) Exception { Configuration conf Configuration(); FileSystem fsFileSystem.get(URI.create(args[]), conf); FSDataInputStream in; { infs.open( Path(args[])); IOUtils.copyBytes(in, System.out, , ); in.seek(); IOUtils.copyBytes(in, System.out, , ); }{ IOUtils.closeStream(in); } } }
hdfs; java.io.InputStream; java.net.URI; org.apache.hadoop.conf.Configuration; org.apache.hadoop.fs.FileSystem; org.apache.hadoop.fs.Path; org.apache.hadoop.io.IOUtils; { main([] args) Exception{ Configuration conf Configuration(); FileSystem fileSystemFileSystem.get(URI.create(args[]), conf); InputStream in; { infileSystem.open( Path(args[])); IOUtils.copyBytes(in, System.out, ,); }{ IOUtils.closeStream(in); } } }
hdfs; org.apache.hadoop.conf.Configuration; org.apache.hadoop.fs.FileStatus; org.apache.hadoop.fs.FileSystem; org.apache.hadoop.fs.FileUtil; org.apache.hadoop.fs.Path; { main([] args) Exception { Configuration conf Configuration(); FileSystem fsFileSystem.get(conf); FileStatus[] fStatusfs.globStatus( Path(args[])); Path[] pathsFileUtil.stat2Paths(fStatus); (Path path:paths){ System.out.println(path); } } }
hdfs; org.apache.hadoop.conf.Configuration; org.apache.hadoop.fs.FileStatus; org.apache.hadoop.fs.FileSystem; org.apache.hadoop.fs.FileUtil; org.apache.hadoop.fs.Path; { main([] args) Exception { Configuration conf Configuration(); FileSystem fsFileSystem.get(conf); FileStatus[] fileStatusesfs.listStatus( Path(args[])); Path[]pathsFileUtil.stat2Paths(fileStatuses); (Path path:paths){ System.out.println(path); } } }
hdfs; org.apache.hadoop.conf.Configuration; org.apache.hadoop.fs.FileSystem; org.apache.hadoop.fs.Path; { main([] args) Exception { Configuration conf Configuration(); FileSystem fsFileSystem.get(conf); fs.mkdirs( Path(args[])); fs.close(); } }
hdfs; org.apache.hadoop.conf.Configuration; org.apache.hadoop.fs.FileStatus; org.apache.hadoop.fs.FileSystem; org.apache.hadoop.fs.FileUtil; org.apache.hadoop.fs.Path; org.apache.hadoop.fs.PathFilter; { PathFilter{ accept(Path path) { (path.getName().startsWith()){ ; }{ ; } } } main([] args) Exception{ Configuration conf Configuration(); FileSystem fsFileSystem.get(conf); FileStatus[] fStatusfs.listStatus( Path(args[]), StartWithPathFilter()); Path [] pathsFileUtil.stat2Paths(fStatus); (Path path:paths){ System.out.println(path); } } }
hdfs; java.io.BufferedInputStream; java.io.FileInputStream; java.io.InputStream; java.io.OutputStream; java.net.URI; org.apache.hadoop.conf.Configuration; org.apache.hadoop.fs.FileSystem; org.apache.hadoop.fs.Path; org.apache.hadoop.io.IOUtils; org.apache.hadoop.util.Progressable; { main([] args) Exception { Configuration conf Configuration(); FileSystem fsFileSystem.get(URI.create(args[]), conf); OutputStream outfs.create( Path(args[]), Progressable() { progress() { System.out.println(); } }); InputStream in BufferedInputStream( FileInputStream(args[])); { IOUtils.copyBytes(in, out, , ); }{ IOUtils.closeStream(in); IOUtils.closeStream(out); } } }
hdfs; java.io.InputStream; java.net.URL; org.apache.hadoop.fs.FsUrlStreamHandlerFactory; org.apache.hadoop.io.IOUtils; { { URL.setURLStreamHandlerFactory( FsUrlStreamHandlerFactory()); } main([] args) Exception{ InputStream in; { in URL(args[]).openStream(); IOUtils.copyBytes(in, System.out, ,); }{ IOUtils.closeStream(in); } } }