shared items

Friday, September 5, 2008

copy File

protected void copyFile(File in, File out) throws IOException
{
byte [] buf = new byte[1024];
int n=0;

try
{
FileInputStream fin = new FileInputStream(in);
FileOutputStream fout = new FileOutputStream(out);
while ((n = fin.read(buf)) > 0)
fout.write(buf, 0, n);
fin.close();
fout.close();
}
catch (IOException e)
{
throw new IOException(e.getMessage());
}
return;
}

No comments: