文件拷贝模板
package IO;
import java.io.*;
public class IOtest04 {
public static void main(String[] args) {
File src=new File("src/IO/abc.txt");
File dest=new File("src/IO/dest.txt");
InputStream is=null;
OutputStream os=null;
try {
is=new FileInputStream(src);
os=new FileOutputStream(dest,true);
byte[] temp=new byte[1024];
int len=-1;
while((len=is.read(temp))!=-1){
os.write(temp,0,len);
}
os.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
if(null!=os){
os.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if(null!=is){
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}