IO 流小记录

File类

构造函数:  FIle file = new File(path);

常用函数:   

是否存在:  file.exists()

文件名: file.getName()

父目录: file.getParent()

=================================================================

 FileInputStream 类

 构造方法: InputStream is = new InputStream(File file)

 常用方法:

 len =  is.read(buffer,off,len);   ---> len = is.read(buffer);

  b     the buffer into which the data is read.

 @return     the total number of bytes read into the buffer, or -1

FileOutputStream 类

构造方法: OutputStream os = new FileOutputStream(File file)

常用方法:

os.write(buffer,0,len)

BufferedInputStream 添加了缓冲区的输入流

构造方法: BufferedInputStream bis = new BufferedInputStream(FileInputStream fis);

常用方法:

bis.read(buffer,0,len);

BufferedOutputStream bos 添加了缓冲区的输出流

构造方法: BufferedOutputStream bos = new BufferedOutputStream(FileOutputStream fos);

常见方法:

bos.write(buffer,0, len);

bos.flush()

bos.close();

猜你喜欢

转载自www.cnblogs.com/lijins/p/10050780.html