public class Copy1 {
public static void main(String[] args) {
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
FileInputStream fis = new FileInputStream("e:/io/1.txt");
FileOutputStream fos = new FileOutputStream("d:/io/1.txt");
bis = new BufferedInputStream(fis);
bos = new BufferedOutputStream(fos);
byte[] b = new byte[1024];
int len = 0;
while((len = bis.read(b)) != -1){
bos.write(b,0,len);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
if(bos != null){
bos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if(bis != null){
bis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Java基础之字节复制
最新推荐文章于 2023-08-04 11:09:09 发布