Description: The java.util.Properties class represents a persistent set of properties. These properties can be saved to a stream or loaded from a stream. Each key and its corresponding value in the properties file are a string. The properties are not sorted, and there is no default ordering.
Code Examples: 1. Removing a key from properties object:
Properties props = new Properties(); props.put("key1", "value1"); props.put("key2", "value2");
//removing key2 props.remove("key2");
2. Load properties from a file and remove:
Properties props = new Properties(); try { FileInputStream in = new FileInputStream("config.properties"); props.load(in); in.close();
//remove the property with the key 'url' props.remove("url");
FileOutputStream out = new FileOutputStream("config.properties"); props.store(out, "My new properties file"); out.close(); } catch (IOException e) { e.printStackTrace(); }
Package Library: The java.util.Properties class is part of the core Java library, so no external package is required. This class can be used in any Java project.
Java Properties.remove - 30 examples found. These are the top rated real world Java examples of java.util.Properties.remove extracted from open source projects. You can rate examples to help us improve the quality of examples.