package exceltest;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class CopyTest {
public static void main(String[] args) {
String oldfilepath = "C:\\Users\\ybb\\Desktop\\test1.txt";
String newfilepath = "D:\\test1.txt";
FileInputStream fileInputStream = null;
FileOutputStream fileOutputStream = null;
try {
fileInputStream = new FileInputStream(oldfilepath);
fileOutputStream = new FileOutputStream(newfilepath,true);
byte[] bytes = new byte[100];
int readlen = 0;
while ((readlen = fileInputStream.read(bytes)) != -1) {
fileOutputStream.write(bytes,0,readlen);
}
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
if (fileInputStream!=null){
fileInputStream.close();
}
if (fileOutputStream!=null){
fileOutputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}