您的位置:首页 > 其它

IO流学习

2016-04-25 19:44 344 查看
字节流:FileInputStream , FileOutputStream

public class IOdemo {

public static void main(String[] args) throws IOException {

File file = new File("F:\\hehe.txt");
FileInputStream in = new FileInputStream(file);
File f = new File("2.txt");
byte[] str = new byte[100];
in.read(str);//读文件信息
String s = new String(str);
System.out.println(s);
in.close();

File file1 = new File("F:\\hello.txt");
FileOutputStream out = new FileOutputStream(file1);
byte[] b = new byte[100];
String data = new String("hello wrold");
b = data.getBytes();
out.write(b);//写文件信息
out.close();

}


}

字符流:FileReader , FileWriter

字节流转字符流:InputStreamReader,OutputStreamWriter

缓冲流(字符串):BufferedReader , BufferedWriter

键盘输入流:System.in , 属于字节输入流

键盘输出流:System.out , 属于字节输出流

数据类型流:DataInputStream,DataOutputStream(字节流)

对象流:ObjectInputStream,ObjectOutputStream(字节流)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: