A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© Java黑马 中级黑马   /  2015-7-5 18:33  /  608 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

I\O流
InputStream类:字节输入流的抽象类,是所有字节输入流的父类。
public class InputStreamDemo {
public static void main(String[] args) {
InputStream in=System.in;
byte[] buf=new byte[1024];
try {
int len=in.read(buf);
String s=new String(buf);
System.out.println(s);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
OutputStream类:字节输出流的抽象类,是所有字节输出流的父类。
public class OutputStreamDemo {
public static void main(String[] args) {
OutputStream out=System.out;
byte[] buf="字节输出流".getBytes();
try {
out.write(buf);
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马