src/share/classes/java/util/Properties.java

Print this page

        

*** 79,90 **** * from other character encodings. * * <p> The {@link #loadFromXML(InputStream)} and {@link * #storeToXML(OutputStream, String, String)} methods load and store properties * in a simple XML format. By default the UTF-8 character encoding is used, ! * however a specific encoding may be specified if required. An XML properties ! * document has the following DOCTYPE declaration: * * <pre> * &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt; * </pre> * Note that the system URI (http://java.sun.com/dtd/properties.dtd) is --- 79,91 ---- * from other character encodings. * * <p> The {@link #loadFromXML(InputStream)} and {@link * #storeToXML(OutputStream, String, String)} methods load and store properties * in a simple XML format. By default the UTF-8 character encoding is used, ! * however a specific encoding may be specified if required. Implementations ! * are required to support UTF-8 and UTF-16 and may support other encodings. ! * An XML properties document has the following DOCTYPE declaration: * * <pre> * &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt; * </pre> * Note that the system URI (http://java.sun.com/dtd/properties.dtd) is
*** 851,877 **** * &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt; * </pre> * Furthermore, the document must satisfy the properties DTD described * above. * * <p>The specified stream is closed after this method returns. * * @param in the input stream from which to read the XML document. * @throws IOException if reading from the specified input stream * results in an <tt>IOException</tt>. * @throws InvalidPropertiesFormatException Data on input stream does not * constitute a valid XML document with the mandated document type. * @throws NullPointerException if {@code in} is null. * @see #storeToXML(OutputStream, String, String) * @since 1.5 */ public synchronized void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException { ! if (in == null) ! throw new NullPointerException(); ! XmlSupport.load(this, in); in.close(); } /** * Emits an XML document representing all of the properties contained --- 852,885 ---- * &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt; * </pre> * Furthermore, the document must satisfy the properties DTD described * above. * + * <p> An implementation is required to read XML documents that use the + * "{@code UTF-8}" or "{@code UTF-16}" encoding. An implementation may + * support additional encodings. + * * <p>The specified stream is closed after this method returns. * * @param in the input stream from which to read the XML document. * @throws IOException if reading from the specified input stream * results in an <tt>IOException</tt>. + * @throws java.io.UnsupportedEncodingException if the document's encoding + * declaration can be read and it specifies an encoding that is not + * supported * @throws InvalidPropertiesFormatException Data on input stream does not * constitute a valid XML document with the mandated document type. * @throws NullPointerException if {@code in} is null. * @see #storeToXML(OutputStream, String, String) + * @see <a href="http://www.w3.org/TR/REC-xml/#charencoding">Character + * Encoding in Entities</a> * @since 1.5 */ public synchronized void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException { ! XmlSupport.load(this, Objects.requireNonNull(in)); in.close(); } /** * Emits an XML document representing all of the properties contained
*** 894,905 **** * @since 1.5 */ public void storeToXML(OutputStream os, String comment) throws IOException { - if (os == null) - throw new NullPointerException(); storeToXML(os, comment, "UTF-8"); } /** * Emits an XML document representing all of the properties contained --- 902,911 ----
*** 908,920 **** * <p>The XML document will have the following DOCTYPE declaration: * <pre> * &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt; * </pre> * ! *<p>If the specified comment is {@code null} then no comment * will be stored in the document. * * <p>The specified stream remains open after this method returns. * * @param os the output stream on which to emit the XML document. * @param comment a description of the property list, or {@code null} * if no comment is desired. --- 914,930 ---- * <p>The XML document will have the following DOCTYPE declaration: * <pre> * &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt; * </pre> * ! * <p>If the specified comment is {@code null} then no comment * will be stored in the document. * + * <p> An implementation is required to support writing of XML documents + * that use the "{@code UTF-8}" or "{@code UTF-16}" encoding. An + * implementation may support additional encodings. + * * <p>The specified stream remains open after this method returns. * * @param os the output stream on which to emit the XML document. * @param comment a description of the property list, or {@code null} * if no comment is desired.
*** 922,945 **** * <a href="../lang/package-summary.html#charenc"> * character encoding</a> * * @throws IOException if writing to the specified output stream * results in an <tt>IOException</tt>. * @throws NullPointerException if {@code os} is {@code null}, * or if {@code encoding} is {@code null}. * @throws ClassCastException if this {@code Properties} object * contains any keys or values that are not * {@code Strings}. * @see #loadFromXML(InputStream) * @since 1.5 */ public void storeToXML(OutputStream os, String comment, String encoding) throws IOException { ! if (os == null) ! throw new NullPointerException(); ! XmlSupport.save(this, os, comment, encoding); } /** * Searches for the property with the specified key in this property list. * If the key is not found in this property list, the default property list, --- 932,958 ---- * <a href="../lang/package-summary.html#charenc"> * character encoding</a> * * @throws IOException if writing to the specified output stream * results in an <tt>IOException</tt>. + * @throws java.io.UnsupportedEncodingException if the encoding is not + * supported by the implementation. * @throws NullPointerException if {@code os} is {@code null}, * or if {@code encoding} is {@code null}. * @throws ClassCastException if this {@code Properties} object * contains any keys or values that are not * {@code Strings}. * @see #loadFromXML(InputStream) + * @see <a href="http://www.w3.org/TR/REC-xml/#charencoding">Character + * Encoding in Entities</a> * @since 1.5 */ public void storeToXML(OutputStream os, String comment, String encoding) throws IOException { ! XmlSupport.save(this, Objects.requireNonNull(os), comment, ! Objects.requireNonNull(encoding)); } /** * Searches for the property with the specified key in this property list. * If the key is not found in this property list, the default property list,