This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes java.lang.OutOfMemoryError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "java.lang.OutOfMemoryError" Watch "java.lang.OutOfMemoryError" New topic


James Laison

Joined: Dec 29, 2005
Posts: 18
Hello friends,

I need an urgent assistance with a project that am working on presently at the moment.

I am trying to read and write data in byte arrays from a file with the use of FileInputStream and then write it to another file with the use of FileOutputStream.

My Code works very fine when handling files lesser than 30MB. When i intend to do such with files above 30MB i get a java.lang.OutOfMemoryError exception and the program stops reading and writing.

In order to be able to avoid this error, i then modified the amount of byte that is being read through FileInputStream to 1MB at a time, so that it keeps reading and writing 1MB of data. But i still get the java.lang.OutOfMemoryError exception and the process stops.

I really need to have this project completed asap. Please help rectify the problem. Below is my code:

I anticipate your prompt response guys.

Joe Ess

Joined: Oct 29, 2001
Posts: 8836

As our FAQ says, Available Doesnt Do What You Think It Does. Have you looked at
RandomAccessFile or do you have to use streams?

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: java.lang.OutOfMemoryError
Similar Threads
how to encrypt data into an image
How to Change the File Name for Each Uploaded Files to the Socket Server?
MultipartRequest cannot be resolved to a type
Mock Exams Help
DataOutputStream / WAVE steganography