1
속성이없는 경우의 .properties 파일의 기존 속성에 새 값을 추가해야하는 다음 코드가 있습니다. 그것은 추가하거나 새로운 설정까지 온 것을 알,코드가 .properties 파일을 변경하지 않는 이유
public String saveProperties(ArrayList<Property> properties, String customerId){
final String userPropFieldName = "users." + customerId + ".rules";
try{
PropertiesConfiguration props = new PropertiesConfiguration("/home/mikhail/bzrrep/DLP/DLPServer/src/main/resources/rules.properties");
for (Property property: properties){
String fieldName = "rules." + property.getName() + "." + property.getType();
String[] values = (property.getValue()).split("\\,");
for (String word: values){
System.out.print(word + " ");
}
if (util.exist(fieldName, props)){
props.setProperty(fieldName, values);
} else {
props.addProperty(fieldName, values);
}
String[] userProperties = props.getStringArray(userPropFieldName);
if (property.getAccepted()){
userProperties = util.addNewValue(userProperties, fieldName);
} else {
userProperties = util.removeValue(userProperties, fieldName);
}
props.setProperty(userPropFieldName, userProperties);
}
}catch (ConfigurationException e){
e.printStackTrace();
}
return "Saved";
}
내가 디버거를 실행하고 모든 값은 바로, 내 말은, 호텔과 배열의 적절한 값의 적절한 이름이있다, 그래서 값이되었지만 마지막으로 속성 파일에 변경 사항이 표시되지 않았습니다.
아, 네. 나는 코드를 바라보고 있었고 문제를 찾을 수 없었다. 그리고 내가 아는 소스 코드를 저장하는 것에 대해서. 일시적입니다. –