/** */
/**
* 实现文件对拷,从F1拷贝到F2,若F2存在则会被覆盖;适用于任何文件.
* @param F1 输入文件的完整路径
* @param F2 输出文件的完整路径
* @throws IOException 读写过程中可能抛出的异常
*/
public boolean saveFileToFileOneByte(String F1, String F2) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(new File(F1)); //建立文件输入流
File file = new File(F2);
fos = new FileOutputStream(F2);
int r;
while ((r = fis.read()) != -1) {
fos.write((byte) r);
}
} catch (FileNotFoundException ex) {
System.out.println("Source File not found:" + F1);
return false;
} catch (IOException ex) {
System.out.println(ex.getMessage());
return false;
} finally {
try {
if (fis != null)
fis.close();//一定要进行文件的关闭,否则在新文件会是空的!
if (fos != null)
fos.close();
} catch (IOException ex) {
System.out.println(ex);
return false;
}
}
return true;
}