java - IOUtils.toByteArray() OutOfMemoryError -


I try to process a larger video file with more than 100 MB size.

  Public static zero compress (file input, file output) throws IOException {InputStream fis = new FileInputStream (input); Byte [] bFile = IOUtils.toByteArray (fis); FileOutputStream fos = New FileOutputStream (Output); GZIPOutputStream gzipStream = new GZIPOutputStream (fos); Try gzipStream.write (bFile); // IOUtils.copy (fis, gzipStream); } Finally {gzipStream.close (); Fis.close (); Fos.close (); }}   

Every time I get an Outmemore Ripper

You must copy the data slowly and you will not be out of memory. InputStream = new FileInputStream (input); OutputStream Out = New GizIIPOutputstream (new file output stream)) { Byte [] bytes = new byte [4096]; (For int lane; (lane = in. Raid (bytes));;; out. Written (bytes, 0, lane); }}

This will use approximately 4 kb as a buffer, regardless of the size of the file. (I suspect that Jeezip uses it to work)

Comments

Popular posts from this blog

c# - passing input text from view to contoller with FacebookContext using Facebook app -

ios - Does Core Data autoupdate a many to many relationship on saving -

Calling a C++ function from C# by passing a string with variable size to it -