I have created a dynamic web project in Eclipse and have written a simple code to read from properties file.
Here is my code
public class AutocompleteService {
public static void main (String args[])
{
Properties properties = new Properties();
properties.load(new FileInputStream("autocomplete.properties"));
System.out.println("Test : " + properties.getProperty("test"));
}
When I run this I got file not found exception.
java.io.FileNotFoundException: autocomplete.properties (The system cannot find the file specified)
My package structure is as below
-src
- com.serive (package)
- AutocompleteService.java
- autocomplete.properties
Both AutocompleteService.java and autocomplete.properties are in same package i.e. com.service.Do we need to anything else to read from properties file ?
Ref: http://www.exampledepot.com/egs/java.util/Props.html
~Ajinkya.
Get the stream relative to your class: