📄 printwriter.java
字号:
// compatibility with JDK 1.2.
write(Float.toString(fnum));
}
/**
* This method prints a double to the stream. The value printed is
* determined using the <code>String.valueOf()</code> method.
*
* @param dnum The <code>double</code> value to be printed
*/
public void print(double dnum) {
// We purposely call write() and not print() here. This preserves
// compatibility with JDK 1.2.
write(Double.toString(dnum));
}
/**
* This method prints an <code>Object</code> to the stream. The actual
* value printed is determined by calling the <code>String.valueOf()</code>
* method.
*
* @param obj The <code>Object</code> to print.
*/
public void print(Object obj) {
// We purposely call write() and not print() here. This preserves
// compatibility with JDK 1.2.
write(obj == null ? "null" : obj.toString());
}
/**
* This is the system dependent line separator
*/
private static final char[] line_separator = System.getProperty("line.separator").toCharArray();
/**
* This method prints a line separator sequence to the stream. The value
* printed is determined by the system property <xmp>line.separator</xmp>
* and is not necessarily the Unix '\n' newline character.
*/
public void println() {
synchronized (lock) {
try {
write(line_separator, 0, line_separator.length);
if (autoflush)
out.flush();
} catch (IOException ex) {
error = true;
}
}
}
/**
* This methods prints a boolean value to the stream. <code>true</code>
* values are printed as "true" and <code>false</code> values are printed
* as "false".
*
* This method prints a line termination sequence after printing the value.
*
* @param bool The <code>boolean</code> value to print
*/
public void println(boolean bool) {
synchronized (lock) {
print(bool);
println();
}
}
/**
* This method prints an integer to the stream. The value printed is
* determined using the <code>String.valueOf()</code> method.
*
* This method prints a line termination sequence after printing the value.
*
* @param inum The <code>int</code> value to be printed
*/
public void println(int inum) {
synchronized (lock) {
print(inum);
println();
}
}
/**
* This method prints a long to the stream. The value printed is
* determined using the <code>String.valueOf()</code> method.
*
* This method prints a line termination sequence after printing the value.
*
* @param lnum The <code>long</code> value to be printed
*/
public void println(long lnum) {
synchronized (lock) {
print(lnum);
println();
}
}
/**
* This method prints a float to the stream. The value printed is
* determined using the <code>String.valueOf()</code> method.
*
* This method prints a line termination sequence after printing the value.
*
* @param fnum The <code>float</code> value to be printed
*/
public void println(float fnum) {
synchronized (lock) {
print(fnum);
println();
}
}
/**
* This method prints a double to the stream. The value printed is
* determined using the <code>String.valueOf()</code> method.
*
* This method prints a line termination sequence after printing the value.
*
* @param dnum The <code>double</code> value to be printed
*/
public void println(double dnum) {
synchronized (lock) {
print(dnum);
println();
}
}
/**
* This method prints an <code>Object</code> to the stream. The actual
* value printed is determined by calling the <code>String.valueOf()</code>
* method.
*
* This method prints a line termination sequence after printing the value.
*
* @param obj The <code>Object</code> to print.
*/
public void println(Object obj) {
synchronized (lock) {
print(obj);
println();
}
}
/**
* This method prints a <code>String</code> to the stream. The actual
* value printed depends on the system default encoding.
*
* This method prints a line termination sequence after printing the value.
*
* @param str The <code>String</code> to print.
*/
public void println(String str) {
synchronized (lock) {
print(str);
println();
}
}
/**
* This method prints a char to the stream. The actual value printed is
* determined by the character encoding in use.
*
* This method prints a line termination sequence after printing the value.
*
* @param ch The <code>char</code> value to be printed
*/
public void println(char ch) {
synchronized (lock) {
print(ch);
println();
}
}
/**
* This method prints an array of characters to the stream. The actual
* value printed depends on the system default encoding.
*
* This method prints a line termination sequence after printing the value.
*
* @param charArray The array of characters to print.
*/
public void println(char[] charArray) {
synchronized (lock) {
print(charArray);
println();
}
}
/**
* This method writes a single char to the stream.
*
* @param ch The char to be written, passed as a int
*/
public void write(int ch) {
try {
out.write(ch);
} catch (IOException ex) {
error = true;
}
}
/**
* This method writes <code>count</code> chars from the specified array
* starting at index <code>offset</code> into the array.
*
* @param charArray The array of chars to write
* @param offset The index into the array to start writing from
* @param count The number of chars to write
*/
public void write(char[] charArray, int offset, int count) {
try {
out.write(charArray, offset, count);
} catch (IOException ex) {
error = true;
}
}
/**
* This method writes <code>count</code> chars from the specified
* <code>String</code> to the output starting at character position
* <code>offset</code> into the <code>String</code>
*
* @param str The <code>String</code> to write chars from
* @param offset The offset into the <code>String</code> to start writing from
* @param count The number of chars to write.
*/
public void write(String str, int offset, int count) {
try {
out.write(str, offset, count);
} catch (IOException ex) {
error = true;
}
}
/**
* This method write all the chars in the specified array to the output.
*
* @param charArray The array of characters to write
*/
public void write(char[] charArray) {
write(charArray, 0, charArray.length);
}
/**
* This method writes the contents of the specified <code>String</code>
* to the underlying stream.
*
* @param str The <code>String</code> to write
*/
public void write(String str) {
write(str, 0, str.length());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -