黑马程序员技术交流社区

标题: IO流---BufferedCopy/定义小数组copy写法 [打印本页]

作者: LARK    时间: 2016-10-14 23:34
标题: IO流---BufferedCopy/定义小数组copy写法
1.BufferedCopy写法:

BufferedInputStream bis= new BufferedInputStream(fis);
BufferedOutputStream bos = new BufferedOutputStream(fos); 相当于:byte[] arr = new byte[8192];
bis.close();
bos.close();
int b = 0;
while(())

2.定义小数组copy写法:

FileInputSream fis = new FileInputStream("xxx.tex"); //创建流对象
FileOutputSream fos = new FileOutputSream("xxx2.text");
byte[] arr = new byte[1024];       //定义一个小数组
int length; //读取到的有效的字节个数
while((length = fis.read(arr))!=-1){fos.write(arr,0,length)}
fis.close();                  忘记写arr的话,读取的是码表值
fos.close();


作者: z443863517    时间: 2016-10-15 00:03
看看。复习复习





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2