JAVA_字节流类

package com.kk.review;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class ByteStream {
/*

InputStream
FileInputStream
ByteArrayInputStream
FilterInputStream //过虑流类
DataInputStream
BufferedInputStream
LineNumberInputStream(开发java编译器使用)
PushbackInputStream(开发java编译器使用)
ObjectInputStream
PipcdInputStream
SquenceInputStream
StringBufferInputStream

OutputStream
FileOutpuStream
ByteArrayOutputStream
FilterOutputStream//过虑流类
DataOutputStream
BufferedOutputStream
PrintStream
ObjectOutputStream
PipcdInputStream

*/
public static void main(String[] args) {
try{
InputStream in=new FileInputStream("a.txt"); //获取输入字节流
BufferedInputStream bis=new BufferedInputStream(in);//带缓冲的字节流
DataInputStream dis=new DataInputStream(bis);//带缓冲的字节流,支持读java的基本数据类型
dis.readInt();
dis.close();//不要忘记关闭流^.^

OutputStream out =new FileOutputStream("a.txt");//获取输出字节流
BufferedOutputStream bos=new BufferedOutputStream(out);//带缓冲的输出字节流
DataOutputStream dos=new DataOutputStream(bos);//带缓冲的输出字节流,支持写java的基本数据类型
dos.writeInt(88);
dos.close();
}catch(FileNotFoundException e){
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}



posted @ 2011-12-09 11:29  microsoft_kk  阅读(3764)  评论(0编辑  收藏  举报