<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-properties</artifactId>
<version>2.12.5</version>
</dependency>
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-properties:2.12.5'
import com.fasterxml.jackson.dataformat.javaprop.JavaPropsMapper;
import com.fasterxml.jackson.dataformat.javaprop.JavaPropsSchema;
public class PropertiesExample {
public static void main(String[] args) throws IOException {
JavaPropsMapper mapper = new JavaPropsMapper();
JavaPropsSchema schema = JavaPropsSchema.emptySchema().withoutPathSeparator();
YourObject yourObject = mapper.readValue(new File("yourFile.properties"), YourObject.class, schema);
mapper.writeValue(new File("yourFile.properties"), yourObject, schema);
}
}
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.javaprop.JavaPropsFactory;
public class CustomPropertiesExample {
public static void main(String[] args) throws IOException {
ObjectMapper mapper = new ObjectMapper(new JavaPropsFactory());
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
YourObject yourObject = mapper.readValue(new File("yourFile.properties"), YourObject.class);
mapper.writeValue(new File("yourFile.properties"), yourObject);
}
}