【发布时间】:2012-09-18 11:02:34
【问题描述】:
我有一个这样组织的项目:
-LIBRERIA CLIENT/
-SRC/
-CONNECTION/
CONNECTIONdB.JAVA
CONFIG.PROPERTIES
在CONNECETIONDB 我有这段代码可以读取CONFIG.PROPERTIES 文件:
public static void connect() throws RemoteException
{
//read file config.properties:
String dbHost="",dbUser="",dbPassword="";
Properties prop=new Properties();
try
{
//load il file:
prop.load(new FileInputStream("src/Connectionconfig.properties"));
//read the property of file
dbHost=prop.getProperty("host");
dbUser=prop.getProperty("user");
dbPassword=prop.getProperty("password");
}catch(FileNotFoundException fe){
System.out.println("File not found");
}catch(IOException ex){
System.out.println("Error reading configuration file");
}
但我有这个错误:
FILE NOT FOUND
谁能告诉我哪里出错了?
【问题讨论】:
-
无需大喊。所有大写都被认为是大喊大叫和粗鲁。
-
大量使用大写锁定对您没有帮助...
-
您认为“找不到文件”是什么意思?
-
你为什么大喊大叫?如果未找到该文件,则表示该文件不在您尝试加载它的位置。
-
如果应用程序在 Web 应用程序上下文中读取,这篇文章可能会对您有所帮助 stackoverflow.com/questions/2308188/…
标签: java properties