运行这个试试
[mw_shl_code=java,true]import java.io.InputStream;
import java.net.URI;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.io.IOUtils;
publicclass FileSystemCat {
publicstaticvoid main(String[] args) throws Exception {
String uri ="hdfs://192.168.1.52:8020/user/data/one/one.txt";
Configuration conf = new Configuration();
FileSystem fs = FileSystem. get(URI.create (uri), conf);
InputStream in = null;
try {
in = fs.open( new Path(uri));
IOUtils.copyBytes(in, System.out, 4096, false);
} finally {
IOUtils.closeStream(in);
}
}
}[/mw_shl_code]
|