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")
также, но он говорит, что путь не признается.
Пожалуйста укажите информацию о местоположении вашего файла свойств и java-файла с вашего компьютера в вопросе. Например: C: /properties/IxFbConfiguration.properties. – sgowd
Можете ли вы выполнить 'ls/properties/IxFbConfiguration.properties' или' dir c: \ properties \ IxFbConfiguration.properties'? –
C: \\ Documents and Settings \\ meenakshib.DCKAP-066 \\ Desktop \\ xblitzjApril18 \\ properties \\ IxFbConfiguration.properties ЭТО ЯВЛЯЕТСЯ ФИЛЕПАТОРОМ – Meenakshi