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:\\ドキュメントと設定\\ meenakshib.DCKAP-066 \\デスクトップ\\ xblitzjApril18 \\プロパティ\\ IxFbConfiguration.propertiesこれはFILEPATHです – Meenakshi