transferring large files
843793Jun 1 2006 — edited Jun 13 2006Hi,
I have to transfer a file from client to the server, its working fine as long as the file size is small.
but when the file size increases it is giving me this error.
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
so what exactly shud i do to transfer files of huge size.
how do i break it down and into small chunks and send it to the server
what is the modification required in the following code:
byte[] buf = new byte[1024];
BufferedInputStream bin = null;
ByteArrayOutputStream bout = null;
try {
FileInputStream fis = new FileInputStream( zipFile );
bout = new ByteArrayOutputStream();
byte[] b = new byte[1024];
int len = 0;
while( (len = fis.read(b, 0, 1024) ) != -1 ) {
bout.write( b, 0, len );
}
System.out.println("Fis available? 0 if yes : 1 if No "+fis.available());
bout.flush();
fileArray = bout.toByteArray();