System類常量 |
描述 |
public static final PrintStream out |
系統(tǒng)標(biāo)準(zhǔn)輸出,一般是顯示器 |
public static final PrintStream err |
錯誤信息輸出 |
public static final InputStream in |
系統(tǒng)標(biāo)準(zhǔn)輸入,一般是鍵盤 |
package System.IO;
import java.io.*;
public class Test {
public static void main(String[] args) throws IOException {
OutputStream out = System.out;
out.write("hello world".getBytes());
System.out.println("\n請輸入一個字符:");
InputStream in = System.in;
byte buffer[] = new byte[20];
int len = 0;
while((len = in.read(buffer))!=-1){
System.out.print(new String(buffer,0,len));
}
}
}
/*
printStream繼承自O(shè)utputStream
它們都是PrintStream類實(shí)例;表示的是一種信息源
System.out對象表示的是向屏幕輸出
System.err對象表示的是輸出錯誤信息(和out一樣的功能,用法,只是表示意義不同)
System.in對象表示的是從鍵盤輸入
*/
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者