字节输入流
InputStream(父类)
FileInputStream(子类)
常用方法:
int read()
int read(byte[] b)
int read(byte[]b ,int off,int len)
void close()
int available()
构造方法:
new FileInputStream(File file)
new FileInputStream(String name)
字节输出流
OutputStream(父类)
FileOutputStream(子类)
常用方法:
void write(int c)
void write(byte[] b)
void write(byte[] b,int off,int len)
void close()
void flush()
构造方法:
FileOutputStream (File file)
FileOutputStream(String name)
FileOutputStream(String name,boolean append)
字符输入流
Reader(父类)
InputStreamReader(子类)//可按指定编码类型来读取数据
常用构造方法:
InputStreamReader(InputStream in)
InputStreamReader(InputStream in,String charsetName)
FileReader(InputStreamReader的子类)//该类只能按照本地平台的字符编码来 读取数据,用户不能指定其他的字符编码类型
常用构造方法:
FileReader(File file)
FileReader(String name)
常用方法:
int read( )
int read(char[] c)
int read(char[] c,int off,int len)
void close( )
字符输出流
Write(父类)
OutputStreamWriter(子类)
常用构造方法:
OutputStreamWriter(OutputStream out)
OutputStreamWriter(OutputStream out,String charsetName)
FileWrite(OutputStreamWriter的子类)//该类只能按照本地平台的字符编码来写数据,用户不能指定其他的字符编码类型
常用构造方法:
FileWriter (File file)
FileWriter (String name)
常用方法:
void write(String str)
void write(String str,int off,int len)
void close()
void flush()
带缓冲区字符输入流
Reader(父类)
BufferedReader(子类)
**常用构造方法:**
BufferedReader(Reader in)
子类BufferedReader特有的方法:
readLine()
使用方法:
Reader fr=new FileReader("C:\\myTest.txt ");
BufferedReader br=new BufferedReader(fr);
带缓冲区字符输出流
Writer(父类)
BufferedWriter(子类)
常用构造方法:
BufferedWriter(Writer out)
使用方法:
FileWriter fw=new
FileWriter("C:\\myTest.txt");
BufferedWriter bw=new BufferedWriter(fw);
读写二进制文件
DataInputStream
与FileInputStream类结合使用读取二进制文件
DataOutputStream类
与FileOutputStream类结合使用写二进制文件