Usage of the properties class

Source: Internet
Author: User
Public class Properties Extends hashtable <object, Object> The properties class represents a persistent property set. Properties can be saved to or loaded from a stream. In the attribute list, each key and its corresponding value are a string.
A property list can contain another property list as its "Default Value". If the attribute key cannot be found in the original property list, the second property list is searched.
Because properties inherits from hashtable, you can apply the put and putall methods to properties objects. However, these two methods are not recommended because they allow callers to insert items whose keys or values are not strings. Instead, use the setproperty method. If the properties object in "insecure" (that is, including non-
To call the store or save method, the call will fail. Similarly, if the propertynames or list method is called on an insecure properties object (that is, a key containing a non-string Key), the call fails.
The load (Reader)/store (writer, string) method loads and stores attributes in character-based streams in the simple row-oriented format specified below. Except that the input/output streams are encoded in ISO 8859-1 characters, the load (inputstream)/store (outputstream, string) method and load (Reader)/store (writer,
String. You can use Unicode escape to compile characters that cannot be directly expressed in this encoding. Only a single 'U' character is allowed in the escape sequence. The native2ascii tool can be used to convert attribute files and other character encodings. The loadfromxml (inputstream) and storetoxml (outputstream, String, string) Methods load and store attributes in a simple XML format. By default, UTF-8 character encoding is used, but you can specify a specific encoding if needed. This class is thread-safe: Multiple Threads can share a single properties object without external synchronization.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.