public static void main(String[] args) {
//需要复制的文件
File oldFile = new File("E:\\upload\\123.txt");
//新的文件路径
File newFile = new File("E:\\upload\\123.txt");
try {
FileInputStream fileStream = new FileInputStream(oldFile);
FileOutputStream fileOut = new FileOutputStream(newFile);
int read = 0;
while ((read = fileStream.read()) != -1) {
fileOut.write(read);
fileOut.flush();
}
fileOut.close();
fileStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
//需要复制的文件
File oldFile = new File("E:\\upload\\123.txt");
//新的文件路径
File newFile = new File("E:\\upload\\123.txt");
try {
FileInputStream fileStream = new FileInputStream(oldFile);
FileOutputStream fileOut = new FileOutputStream(newFile);
int read = 0;
while ((read = fileStream.read()) != -1) {
fileOut.write(read);
fileOut.flush();
}
fileOut.close();
fileStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}