add PrintStream.print[ln] overloads for primitives and char arrays

This commit is contained in:
Joel Dice 2011-01-20 08:26:56 -07:00
parent 9c36105b8f
commit 51c56c1b3c
2 changed files with 56 additions and 0 deletions

View File

@ -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);

View File

@ -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' });
}
}