Re: Copy files in java gives me out of memory error
- From: Chase Preuninger <chasepreuninger@xxxxxxxxx>
- Date: Sun, 30 Dec 2007 17:14:10 -0800 (PST)
Not sure why. The other day I worte a spell check that loads the
entire english language into memory, and I had no prolbems. The
follownig code works for me. Also it is probably faster than yours,
and works great with any type of file.
public static void makeCopy(File from, File to) throws IOException
{
if(!to.exists())
{
to.createNewFile();
}
InputStream in = new FileInputStream(from);
OutputStream out = new BufferedOutputStream(new
FileOutputStream(to));
int b;
while((b = in.read()) != -1)
{
out.write(b);
}
out.flush();
in.close();
out.close();
}
.
- Follow-Ups:
- Re: Copy files in java gives me out of memory error
- From: Jeff Higgins
- Re: Copy files in java gives me out of memory error
- References:
- Copy files in java gives me out of memory error
- From: Canned
- Copy files in java gives me out of memory error
- Prev by Date: Re: question about the toString Method
- Next by Date: KeyListener not working
- Previous by thread: Re: Copy files in java gives me out of memory error
- Next by thread: Re: Copy files in java gives me out of memory error
- Index(es):
Relevant Pages
|