package sxt1102;
import java.io.*;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
File file = new File("c:/pan.txt");
File file2 = new File("c:/pan2.txt");
if(file.exists()){
try {
FileInputStream fileInputStream = new FileInputStream(file);
byte []b=new byte[(int) file.length()];
fileInputStream.read(b);
fileInputStream.close();
FileOutputStream fileOutputStream = new FileOutputStream(file2);
fileOutputStream.write(b);
fileOutputStream.close();
System.out.println("文件复制成功!");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
import java.io.*;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
File file = new File("c:/pan.txt");
File file2 = new File("c:/pan2.txt");
if(file.exists()){
try {
FileInputStream fileInputStream = new FileInputStream(file);
byte []b=new byte[(int) file.length()];
fileInputStream.read(b);
fileInputStream.close();
FileOutputStream fileOutputStream = new FileOutputStream(file2);
fileOutputStream.write(b);
fileOutputStream.close();
System.out.println("文件复制成功!");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}