aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/util
diff options
context:
space:
mode:
authorRanjit Mathew <rmathew@hotmail.com>2003-02-17 19:05:56 +0000
committerTom Tromey <tromey@gcc.gnu.org>2003-02-17 19:05:56 +0000
commitbea63b0accf638e9b45b75efc2b75a746aba88a6 (patch)
treea6dc5e410e218a64c0f824d16ba4e57464752d91 /libjava/java/util
parent130cd3e1df2476eda6e01c82ace326db4f85e24e (diff)
downloadgcc-bea63b0accf638e9b45b75efc2b75a746aba88a6.zip
gcc-bea63b0accf638e9b45b75efc2b75a746aba88a6.tar.gz
gcc-bea63b0accf638e9b45b75efc2b75a746aba88a6.tar.bz2
Properties.java (store): Move the code formerly in list(), into this method.
2003-02-17 Ranjit Mathew <rmathew@hotmail.com> * java/util/Properties.java (store): Move the code formerly in list(), into this method. (list (PrintStream)): Just call list (PrintWriter) with a PrintWriter object constructed from the given PrintStream object. (list (PrintWriter)): Emulate the output of Properties.list() as found in JDK 1.3/1.4. From-SVN: r63006
Diffstat (limited to 'libjava/java/util')
-rw-r--r--libjava/java/util/Properties.java74
1 files changed, 41 insertions, 33 deletions
diff --git a/libjava/java/util/Properties.java b/libjava/java/util/Properties.java
index 907ec2c..279cf1e 100644
--- a/libjava/java/util/Properties.java
+++ b/libjava/java/util/Properties.java
@@ -377,9 +377,21 @@ label = Name:\\u0020</pre>
= new PrintWriter(new OutputStreamWriter(out, "ISO-8859-1"));
if (header != null)
writer.println("#" + header);
- writer.println("#" + new Date());
- list(writer);
- writer.flush();
+ writer.println ("#" + Calendar.getInstance ().getTime ());
+
+ Iterator iter = entrySet ().iterator ();
+ int i = size ();
+ StringBuffer s = new StringBuffer (); // Reuse the same buffer.
+ while (--i >= 0)
+ {
+ Map.Entry entry = (Map.Entry) iter.next ();
+ formatForOutput ((String) entry.getKey (), s, true);
+ s.append ('=');
+ formatForOutput ((String) entry.getValue (), s, false);
+ writer.println (s);
+ }
+
+ writer.flush ();
}
/**
@@ -453,54 +465,50 @@ label = Name:\\u0020</pre>
}
/**
- * Writes the key/value pairs to the given print stream. They are
- * written in the way described in the method store. This does not visit
- * the keys in the default properties.
+ * Prints the key/value pairs to the given print stream. This is
+ * mainly useful for debugging purposes.
*
- * @param out the stream, where the key/value pairs are written to
- * @throws ClassCastException if this property contains any key or
+ * @param out the print stream, where the key/value pairs are written to
+ * @throws ClassCastException if this property contains a key or a
* value that isn't a string
- * @see #store(OutputStream, String)
+ * @see #list(PrintWriter)
*/
public void list(PrintStream out)
{
- Iterator iter = entrySet().iterator();
- int i = size();
- StringBuffer s = new StringBuffer(); // Reuse the same buffer.
- while (--i >= 0)
- {
- Map.Entry entry = (Map.Entry) iter.next();
- formatForOutput((String) entry.getKey(), s, true);
- s.append('=');
- formatForOutput((String) entry.getValue(), s, false);
- out.println(s);
- }
+ PrintWriter writer = new PrintWriter (out);
+ list (writer);
}
/**
- * Writes the key/value pairs to the given print writer. They are
- * written in the way, described in the method store.
+ * Prints the key/value pairs to the given print writer. This is
+ * mainly useful for debugging purposes.
*
- * @param out the writer, where the key/value pairs are written to
- * @throws ClassCastException if this property contains any key or
+ * @param out the print writer where the key/value pairs are written to
+ * @throws ClassCastException if this property contains a key or a
* value that isn't a string
- * @see #store(OutputStream, String)
* @see #list(PrintStream)
* @since 1.1
*/
public void list(PrintWriter out)
{
- Iterator iter = entrySet().iterator();
- int i = size();
- StringBuffer s = new StringBuffer(); // Reuse the same buffer.
+ out.println ("-- listing properties --");
+
+ Iterator iter = entrySet ().iterator ();
+ int i = size ();
while (--i >= 0)
{
- Map.Entry entry = (Map.Entry) iter.next();
- formatForOutput((String) entry.getKey(), s, true);
- s.append('=');
- formatForOutput((String) entry.getValue(), s, false);
- out.println(s);
+ Map.Entry entry = (Map.Entry) iter.next ();
+ out.print ((String) entry.getKey () + "=");
+
+ // JDK 1.3/1.4 restrict the printed value, but not the key,
+ // to 40 characters, including the truncating ellipsis.
+ String s = (String ) entry.getValue ();
+ if (s != null && s.length () > 40)
+ out.println (s.substring (0, 37) + "...");
+ else
+ out.println (s);
}
+ out.flush ();
}
/**