Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1472
  • Last Modified:

java.io.FileNotFoundException

Hi,
 
 I am working on standalone application using Netbeans. This is not web and desktop application
 
 This is java application
 
 I have created AppConfig.properties file and is created on the root of the source packages
 
 My system is not reading the file AppConfig.properties
 
 I have also tried it movong into the folder where main file exists
 
 But no luck. I donot wanted to hardcode path within the application
 
 
 The Error message says
 
 java.io.FileNotFoundException: AppConfig.properties (The system cannot find the file specified)
       at java.io.FileInputStream.open(Native Method)
       at java.io.FileInputStream.<init>(FileInputStream.java:106)
       at java.io.FileInputStream.<init>(FileInputStream.java:66)
       at mccprocesswatcher.Main.readRegistrationXMLs(Main.java:50)
      at mccprocesswatcher.Main.main(Main.java:42)
      

Please help me to fix this

Many Thanks
Properties properties = new Properties();
try {
	properties.load(new FileInputStream("AppConfig.properties"));
 
	String strPropertyValue = properties.getProperty("FtpDirectoryPath");
	mL.info("Property Read: "+strPropertyValue);
} catch (IOException e) {
 
    mL.error("Property file not read: " ,e);
}

Open in new window

0
tia_kamakshi
Asked:
tia_kamakshi
1 Solution
 
CEHJCommented:
Try the following. Place the file in the directory which is the parent of your package tree
InputStream in = getClass().getResourceAsStream("/AppConfig.properties");
properties.load(in);
in.close();

Open in new window

0
 
bluebelldiscoveryCommented:
If "AppConfig.properties" file is place at
root of "compile class folder" then it should be fine.
0
 
tia_kamakshiAuthor Commented:
Many Many Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now