377 |
= new PrintWriter(new OutputStreamWriter(out, "ISO-8859-1")); |
= new PrintWriter(new OutputStreamWriter(out, "ISO-8859-1")); |
378 |
if (header != null) |
if (header != null) |
379 |
writer.println("#" + header); |
writer.println("#" + header); |
380 |
writer.println("#" + new Date()); |
writer.println ("#" + Calendar.getInstance ().getTime ()); |
381 |
list(writer); |
|
382 |
writer.flush(); |
Iterator iter = entrySet ().iterator (); |
383 |
|
int i = size (); |
384 |
|
StringBuffer s = new StringBuffer (); // Reuse the same buffer. |
385 |
|
while (--i >= 0) |
386 |
|
{ |
387 |
|
Map.Entry entry = (Map.Entry) iter.next (); |
388 |
|
formatForOutput ((String) entry.getKey (), s, true); |
389 |
|
s.append ('='); |
390 |
|
formatForOutput ((String) entry.getValue (), s, false); |
391 |
|
writer.println (s); |
392 |
|
} |
393 |
|
|
394 |
|
writer.flush (); |
395 |
} |
} |
396 |
|
|
397 |
/** |
/** |
465 |
} |
} |
466 |
|
|
467 |
/** |
/** |
468 |
* Writes the key/value pairs to the given print stream. They are |
* Prints the key/value pairs to the given print stream. This is |
469 |
* written in the way described in the method store. This does not visit |
* mainly useful for debugging purposes. |
|
* the keys in the default properties. |
|
470 |
* |
* |
471 |
* @param out the stream, where the key/value pairs are written to |
* @param out the print stream, where the key/value pairs are written to |
472 |
* @throws ClassCastException if this property contains any key or |
* @throws ClassCastException if this property contains a key or a |
473 |
* value that isn't a string |
* value that isn't a string |
474 |
* @see #store(OutputStream, String) |
* @see #list(PrintWriter) |
475 |
*/ |
*/ |
476 |
public void list(PrintStream out) |
public void list(PrintStream out) |
477 |
{ |
{ |
478 |
Iterator iter = entrySet().iterator(); |
PrintWriter writer = new PrintWriter (out); |
479 |
int i = size(); |
list (writer); |
|
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); |
|
|
} |
|
480 |
} |
} |
481 |
|
|
482 |
/** |
/** |
483 |
* Writes the key/value pairs to the given print writer. They are |
* Prints the key/value pairs to the given print writer. This is |
484 |
* written in the way, described in the method store. |
* mainly useful for debugging purposes. |
485 |
* |
* |
486 |
* @param out the writer, where the key/value pairs are written to |
* @param out the print writer where the key/value pairs are written to |
487 |
* @throws ClassCastException if this property contains any key or |
* @throws ClassCastException if this property contains a key or a |
488 |
* value that isn't a string |
* value that isn't a string |
|
* @see #store(OutputStream, String) |
|
489 |
* @see #list(PrintStream) |
* @see #list(PrintStream) |
490 |
* @since 1.1 |
* @since 1.1 |
491 |
*/ |
*/ |
492 |
public void list(PrintWriter out) |
public void list(PrintWriter out) |
493 |
{ |
{ |
494 |
Iterator iter = entrySet().iterator(); |
out.println ("-- listing properties --"); |
495 |
int i = size(); |
|
496 |
StringBuffer s = new StringBuffer(); // Reuse the same buffer. |
Iterator iter = entrySet ().iterator (); |
497 |
|
int i = size (); |
498 |
while (--i >= 0) |
while (--i >= 0) |
499 |
{ |
{ |
500 |
Map.Entry entry = (Map.Entry) iter.next(); |
Map.Entry entry = (Map.Entry) iter.next (); |
501 |
formatForOutput((String) entry.getKey(), s, true); |
out.print ((String) entry.getKey () + "="); |
502 |
s.append('='); |
|
503 |
formatForOutput((String) entry.getValue(), s, false); |
// JDK 1.3/1.4 restrict the printed value, but not the key, |
504 |
out.println(s); |
// to 40 characters, including the truncating ellipsis. |
505 |
|
String s = (String ) entry.getValue (); |
506 |
|
if (s != null && s.length () > 40) |
507 |
|
out.println (s.substring (0, 37) + "..."); |
508 |
|
else |
509 |
|
out.println (s); |
510 |
} |
} |
511 |
|
out.flush (); |
512 |
} |
} |
513 |
|
|
514 |
/** |
/** |