System 类对IO操作的支持
System类的对象:public static final PrintStream out ---将输出定位到显示器,FileOutputStream 定位到文件中一样
Public static final PrintStream in
Public static final PrintStream err
备注:err out 是PrintStream的对象 in是InputStream 的对象
import java.io.*;
public class Systemclass {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
OutputStream out=System.out;
try{
out.write("hello,Aric".getBytes());
}catch(IOException e){
e.printStackTrace();
}
try {
out.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
System.in
InputStream input=System.in;
byte[] b=new byte[1024];
System.out.println("请输入数字:");
int len=0;
try {
len=input.read(b);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
System.out.println(new String(b,0,len) ); |
|