使用java操作HDFS(一)
1.编辑一个文件并通过hadoop命令将其放到HDFS中
2.使用java代码访问所上传的文件
private final static String PATH = "hdfs://hadoop:9000/hello"; public static void main(String[] args) throws Exception { URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory()); URL url = new URL(PATH); InputStream in = url.openStream(); IOUtils.copyBytes(in, System.out, 1024, true); }