< prev index next >
src/java.base/share/classes/java/io/PrintStream.java
Print this page
rev 15365 : imported patch 8163517-Various-cleanup-in-java-io-code
@@ -566,11 +566,11 @@
* {@link #write(int)} method.
*
* @param b The {@code boolean} to be printed
*/
public void print(boolean b) {
- write(b ? "true" : "false");
+ write(String.valueOf(b));
}
/**
* Prints a character. The character is translated into one or more bytes
* according to the platform's default character encoding, and these bytes
@@ -661,14 +661,11 @@
* {@link #write(int)} method.
*
* @param s The {@code String} to be printed
*/
public void print(String s) {
- if (s == null) {
- s = "null";
- }
- write(s);
+ write(String.valueOf(s));
}
/**
* Prints an object. The string produced by the {@link
* java.lang.String#valueOf(Object)} method is translated into bytes
@@ -1066,14 +1063,11 @@
* @return This output stream
*
* @since 1.5
*/
public PrintStream append(CharSequence csq) {
- if (csq == null)
- print("null");
- else
- print(csq.toString());
+ print(String.valueOf(csq));
return this;
}
/**
* Appends a subsequence of the specified character sequence to this output
@@ -1109,13 +1103,12 @@
* {@code csq.length()}
*
* @since 1.5
*/
public PrintStream append(CharSequence csq, int start, int end) {
- CharSequence cs = (csq == null ? "null" : csq);
- write(cs.subSequence(start, end).toString());
- return this;
+ if (csq == null) csq = "null";
+ return append(csq.subSequence(start, end));
}
/**
* Appends the specified character to this output stream.
*
< prev index next >