J2EE Eclipse Project and properties file
I am trying to run the ff code:
if(properties == null || properties.isEmpty()){
properties = new Properties();
File file = new File("settings/databasesetting.properties");
System.out.println("File path : "+file.getAbsolutePath());
try {
FileInputStream stream = new FileInputStream(file);
properties. load (stream);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
And I get the ff exception:
File path :
C:\Development\Java\infosys\settings\databasesetting.properties
java.io.FileNotFoundException: settings\databasesetting.properties (The
system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream. (FileInputStream.java:106)
at com.web.database.Database. (Database.java:191)
at com.web.database.Database.main(Database.java:570)
Connection = null
java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at
com.web.database.DatabaseManager.getConnection(DatabaseManager.java:74)
at com.web.database.Database. (Database.java:200)
at com.web.database.Database.main(Database.java:570)
The strangest thing is that a file can be created using the given
properties file, but I don't understand why an input strean cannot be
created.
Please help, what am I doing wrong?
Thanks in advance.
Yours,
Me