You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by Shimi K <sh...@gmail.com> on 2008/04/16 06:30:05 UTC

Re: Reading Configuration File

Just put it in the classpath

On Tue, Apr 15, 2008 at 11:50 PM, Natarajan, Senthil <se...@pitt.edu>
wrote:

> Hi,
> How to read configuration file in Hadoop.
> I tried by copying the file in HDFS and also placing within the jar file.
>
> I tried like this in Map constructor
> Configuration conf = new Configuration();
>          FileSystem fs = FileSystem.get(conf);
>          Path inFile = new Path("/file/path/configfile.txt");
>          FSDataInputStream in = fs.open(inFile);
>          properties.load(in);
>          in.close();
>
> And also like this
> //URL url = UserPattern2.class.getResource(commFile);
>          URL url = new URL("/file/path/configfile.txt");
>          if( url != null ) {
>             InputStream in = url.openStream();
>             properties.load(in);
>             in.close();
>          }
>
> Looks like it is not finding the file seems, I am getting
> NullPointerException.
> Here I am opening file and loading into Java Properties object.
>
> Please let me know what might be the problem.
>
> Thanks,
> Senthil
>