0
String inputPath = args[0];
FileSystem dfs = new DistributedFileSystem();
FileStatus[] files= null;
try{
     files = dfs.listStatus(new path(inputPath));
}
catch(IOExcpeption err){
    //Do stuff
}

The code build fine with maven. However, when I try to run it, I get a nullPointerException inside the try clause. Any ideas?

CalebJ
  • 159
  • 1
  • 10
  • I've almost figured it out. I need to initialize dfs using dfs.initialize(new URI, new Configuration) where URI is a plain java class and Configuration is from hadoop-core in org.apache.hadoop. – CalebJ Mar 24 '14 at 06:07

1 Answers1

0

Instantiating a FileSystem class requires a Configuration object in the constructor. One very simply way to do this is with the following:

FileSystem lfs = FileSystem.get(new Configuration());

Use this when creating the FileSystem object. This also has the added bonus of using the local configuration, so you don't have to change your code when switching between a hadoop and a local file structure.

CalebJ
  • 159
  • 1
  • 10