Programmatically reading the output of Hadoop Mapreduce Program

前端 未结 3 588
忘掉有多难
忘掉有多难 2021-02-09 02:26

This may be a basic question, but I could not find an answer for it on Google.
I have a map-reduce job that creates multiple output files in its output directory. My Java a

3条回答
  •  执念已碎
    2021-02-09 03:03

                FSDataInputStream inputStream = fs.open(path);
                BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
                String record;
                while((record = reader.readLine()) != null) {
                    int blankPos = record.indexOf(" ");
                    System.out.println(record+"blankPos"+blankPos);
                    String keyString = record.substring(0, blankPos);
                    String valueString = record.substring(blankPos + 1);
                    System.out.println(keyString + " | " + valueString);
                }
    

提交回复
热议问题