I'm trying to read the contents of a file from HDFS. My code is below -
package gen;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
public class ReadFromHDFS {
public static void main(String[] args) throws Exception {
if (args.length < 1) {
System.out.println("Usage: ReadFromHDFS ");
System.out.println("Example: ReadFromHDFS 'hdfs:/localhost:9000/myFirstSelfWriteFile'");
System.exit(-1);
}
try {
Path path = new Path(args[0]);
FileSystem fileSystem = FileSystem.get(new Configuration());
BufferedReader bufferedReader