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?
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.