- package com.itheima.copyfile;
- import java.io.BufferedInputStream;
- import java.io.BufferedOutputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- public class CopyByBufferedInputStream {
- public static void main(String[] args) throws IOException {
- File source_file = new File("c:\\1.jpg");
- File destination_file = new File("c:\\2.jpg");
- BufferedInputStream bis = new BufferedInputStream(new FileInputStream(source_file));
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(destination_file));
- int ch = 0;
- while ((ch = bis.read()) != -1) {
- bos.write(ch);
- }
- bis.close();
- bos.close();
- }
- }
复制代码
|