HDFS Java API按行读取

2018.10.28

文章目录

前言

翻译自stackoverflow一回答1

方法

public void test() throws Exception {
	Path path = new Path("hdfs://pathToFile");
	FileSystem fs = FileSystem.get(context.getConfiguration);
	BufferedReader reader = new BufferedReader(new InputStreamReader(fs.open(path)));
	String line;
	while ((line = reader.readLine()) != null) {
		System.out.println(line);
	}
	reader.close();
}

  1. stackoverflow回答 ↩︎

猜你喜欢

转载自blog.csdn.net/m0_37793798/article/details/83309301