标签:进制 png void pre buffer 文件 二进制 常用方法 finally
?
BufferedInputStream和BufferedOutputStream
?
import java.io.*;
public class BufferCopy {
public static void main(String[] args) {
//定义一个高效缓存字节流
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
//创建一个高效缓存字节流对象
in = new BufferedInputStream(new FileInputStream("C:/yonige.png"));
out = new BufferedOutputStream(new FileOutputStream("D:/ComingSpring.png"));
//定义一个字节数组
byte[] bs = new byte[1024];
//定义一个标志
int len = -1;
while((len = in.read(bs)) != -1){
out.write(bs, 0, len);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if(out != null){
out.close();
}
if(in != null){
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
标签:进制 png void pre buffer 文件 二进制 常用方法 finally
原文地址:https://www.cnblogs.com/seviyan/p/11657925.html