File f = new File("d:\\ibatis.log");
File f1 = new File("d:\\ibatis2.log");
byte b[] = new byte[1024];
int l = 0;
char c[] = new char[1024];
String str = "";
try
{
/**
* 文件复制方法1
*/
FileInputStream fis = new FileInputStream(f);
FileOutputStream fos = new FileOutputStream(f1);
while ((l = fis.read(b)) > 0)
{
fos.write(b);
}
/**
* 文件复制方法2
*/
FileReader fr = new FileReader(f);
FileWriter fw = new FileWriter(f1);
while ((l = fr.read(c)) > 0)
{
fw.write(c);
}
/**
* 文件复制方法3
*/
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
while ((str = br.readLine()) != null)
{
bw.write(str);
}
}
catch (IOException e)
{
e.printStackTrace();
}