[jboss-user] [JBoss Seam] - Re: Max file upload --Out of memory error

jamesjmp do-not-reply at jboss.com
Thu Jan 17 03:48:11 EST 2008


hi,
I had the same problem with files time ago. I solved it using InputStream , BufferedInputStream and flushing. For instance:


  | FileOutputStream fw = ...whatever...
  | String filename = ...whatever...
  | InputStream in = null;
  | int bytesRead;
  | try {
  |             in = new BufferedInputStream(new FileInputStream(filename));
  |             byte[] buf = new byte[4 * 1024]; // 4K buffer
  |             while ((bytesRead = in.read(buf)) != -1) {
  |                 out.write(buf, 0, bytesRead);
  |                 out.flush();
  |             }
  |             if (in != null)
  |                 in.close();
  |         } catch (Throwable tt) {
  |             tt.printStackTrace();
  |         }
  |     

Hope it helps you! 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120749#4120749

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120749



More information about the jboss-user mailing list