Io流之实现文件的复制
package Io流;
import org.junit.Test;
import java.io.*;
/**
* 实现文件的复制
*/
public class Demo04 {
@Test
public void test(){
FileInputStream fis = null;
FileOutputStream fos = null;
try {
File file = new File("d:\\11.txt");
//输入流
fis = new FileInputStream(file);
//输出流
fos = new FileOutputStream("e:\\11.txt",true);
int ch = 0;
while ((ch = fis.read())!= -1){
fos.write(ch);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fos.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
人生不易,多多努力!!!
浙公网安备 33010602011771号