- 考了两次了都没完全写出来
-
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- public class CopyFile {
- private boolean copy() {
- try {
- FileInputStream in = new java.io.FileInputStream(new File("a1.java"));
- BufferedInputStream bis = new BufferedInputStream(in);
- FileOutputStream out = new FileOutputStream(new File("a2.java"));
-
- byte[] bt = new byte[1024];
- int count;
- while ((count = bis.read(bt)) > 0) {
- out.write(bt, 0, count);
- }
- in.close();
- out.close();
- return true;
- } catch (IOException ex) {
- return false;
- }
- }
- }