Thanks. That worked.
----- Original Message ---- From: Jeff Zhang <zjf...@gmail.com> To: common-user@hadoop.apache.org Sent: Sat, December 26, 2009 4:13:44 AM Subject: Re: reading sequence Files on local file system The NullPointerException is because the Configuration of your FileSystem is null. So use FileSystem.getLocal(new Configuration()) instead of new LocalFileSystem() Jeff Zhang On Sat, Dec 26, 2009 at 12:20 AM, himanshu chandola < himanshu_cool...@yahoo.com> wrote: > Hi Everyone, > I was trying to read a Sequence File which i moved from HDFS to my local > file system in a java program. To do this i used SequenceFile.Reader. > > The following is the constructor for SequenceFile.Reader which generates an > exception: > > SequenceFile.Reader sfr = new SequenceFile.Reader(new LocalFileSystem(), > new Path(inputFile), new Configuration()); > > where inputFile is a path like /home/user/inputSeq.dat > and the exception: > > Exception in thread "main" java.lang.NullPointerException > at > org.apache.hadoop.fs.FileSystem.getDefaultBlockSize(FileSystem.java:1270) > at > org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:359) > at > org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:245) > at org.apache.hadoop.fs.FileSystem.getLength(FileSystem.java:671) > at > org.apache.hadoop.io.SequenceFile$Reader.<init>(SequenceFile.java:1417) > at > org.apache.hadoop.io.SequenceFile$Reader.<init>(SequenceFile.java:1412) > at TestSequenceR.main(TestSequenceR.java:12) > > I packaged the program to read the sequence file into a jar and ran it as > java -jar. I wanted to avoid using hadoop for this since while reading the > file I will have shared variables and the file is not that big to merit > using hadoop on a cluster for this step. > > So I feel I am missing something elementary on this. I thought just > importing SequenceFile.Reader would do the job for me but supposedly it does > not. > > It would be great if someone could throw more light on this. > > Thanks > H > > > > >