问题
I have some MapReduce job and I would like to use the output file of Reducer further in Java code. How can I read from such a file, since it's on distributed file system?
Thanks
回答1:
Since you want to use output file of Reducer further in a simple java code, for that you can use the following code:-
` try{
Path pt=new Path("hdfs://npvm11.np.wc1.yellowpages.com:9000/user/john/abc.txt");
FileSystem fs = FileSystem.get(new Configuration());
BufferedReader br=new BufferedReader(new InputStreamReader(fs.open(pt)));
String line;
line=br.readLine();
while (line != null){
System.out.println(line);
line=br.readLine();
}
}
catch(Exception e){
}`
Replace the address with the address of file which you want to use in java code.
来源:https://stackoverflow.com/questions/27617971/read-from-reducer-output-file