From 51c56c1b3c901354a1ae8fad290b00a7436f41c5 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 20 Jan 2011 08:26:56 -0700 Subject: [PATCH] add PrintStream.print[ln] overloads for primitives and char arrays --- classpath/java/io/PrintStream.java | 48 ++++++++++++++++++++++++++++++ test/Misc.java | 8 +++++ 2 files changed, 56 insertions(+) diff --git a/classpath/java/io/PrintStream.java b/classpath/java/io/PrintStream.java index 520b676a29..a720fac6a0 100644 --- a/classpath/java/io/PrintStream.java +++ b/classpath/java/io/PrintStream.java @@ -39,10 +39,34 @@ public class PrintStream extends OutputStream { print(String.valueOf(o)); } + public void print(boolean v) { + print(String.valueOf(v)); + } + public void print(char c) { print(String.valueOf(c)); } + public void print(int v) { + print(String.valueOf(v)); + } + + public void print(long v) { + print(String.valueOf(v)); + } + + public void print(float v) { + print(String.valueOf(v)); + } + + public void print(double v) { + print(String.valueOf(v)); + } + + public void print(char[] s) { + print(String.valueOf(s)); + } + public synchronized void println(String s) { try { out.write(s.getBytes()); @@ -62,9 +86,33 @@ public class PrintStream extends OutputStream { println(String.valueOf(o)); } + public void println(boolean v) { + println(String.valueOf(v)); + } + public void println(char c) { println(String.valueOf(c)); } + + public void println(int v) { + println(String.valueOf(v)); + } + + public void println(long v) { + println(String.valueOf(v)); + } + + public void println(float v) { + println(String.valueOf(v)); + } + + public void println(double v) { + println(String.valueOf(v)); + } + + public void println(char[] s) { + println(String.valueOf(s)); + } public void write(int c) throws IOException { out.write(c); diff --git a/test/Misc.java b/test/Misc.java index 8a501392c7..7ff2f25378 100644 --- a/test/Misc.java +++ b/test/Misc.java @@ -227,5 +227,13 @@ public class Misc { } System.out.println(new java.util.Date().toString()); + + System.out.println('x'); + System.out.println(true); + System.out.println(42); + System.out.println(123456789012345L); + System.out.println(75.62); + System.out.println(75.62d); + System.out.println(new char[] { 'h', 'i' }); } }