public boolean WriteProperty(String key,String value){
try{
int check=0;
while(check == 0){
check=1;
Properties pro = new Properties();
File f = new File("/properties/IxFbConfiguration.properties");
if(!f.exists()){
check=0;
System.out.println("File not found!");
}
else{
FileInputStream in = new FileInputStream(f);
pro.load(in);
System.out.print("Enter Key : ");
System.out.print("Enter Value : ");
pro.setProperty(key, value);
System.out.println("the property is"+pro.getProperty(key));
// pro.store(new FileOutputStream(str + ".properties"),null);
pro.store(new FileOutputStream("/properties/IxFbConfiguration.properties"),null);
System.out.println("Operation completly successfuly!");
}
}
}
catch(IOException e){
System.out.println(e.getMessage());
}
return false;
}
运行此代码时出现文件未找到异常。
我确实有一个包含该IxFbConfiguration.properties
文件的文件夹属性。当我将完整路径硬编码为
C:\Documents and Settings\meenakshib.DCKAP-066\Desktop\xblitzjApril18\properties\IxFbConfiguration.properties 时,它可以工作。
但是当我使用罐子时我遇到了问题。我尝试使用
getClass().getResourceAsStream("/properties/IxFbConfiguration.properties")
也,但它说路径无法识别。