Property File

Still confused where you have to put a property files in your java project? This code for loads a property file located anywhere in your classpath.

public Properties getPropertiesFromClasspath(String propFileName)
  throws IOException {
  // loading from the classpath
  Properties props = new Properties();
  InputStream inputStream = this.getClass().getClassLoader()

  if (inputStream == null) {
    throw new FileNotFoundException("property file not found "+
      "in the classpath");

  return props;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s