Skip to content

Instantly share code, notes, and snippets.

@muthugit
Created October 4, 2016 12:42
Show Gist options
  • Save muthugit/d2d0485473e8ba56f1fcf443e6454b46 to your computer and use it in GitHub Desktop.
Save muthugit/d2d0485473e8ba56f1fcf443e6454b46 to your computer and use it in GitHub Desktop.
Read and print file
package hadoop;
import java.io.*;
import java.util.*;
import java.net.*;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;
public class Cat {
public static void main(String[] args) throws Exception {
try {
Path pt = new Path("hdfs://localhost:9000/hadoop/transaction.csv");
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) {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment