• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.OutOfMemoryError

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Iam facing with one problem.Iam uploading file from swing Interface through servlet.Now when I select above 4mb size of file then it giving me error On Dos-prompt.My servlet working perfectly with html form with any size of file coz in my servlet I can set the accept size of file.plz guide me how I can slove the problem.Below r codes:-
ImageIcon Upload=new ImageIcon("images/Upload.gif");
Button=new JButton(Upload);
Button.setToolTipText("Upload");

Button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
int returnVal = fc.showOpenDialog(ActionDemo4.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
String aa=file.getAbsolutePath();
textArea3.append(aa);
textArea2.append("Local URL:");
long l=file.length();
try
{
byte buff[]=new byte[(int)file.length()];
InputStream fileIn=new FileInputStream(aa);
int i=fileIn.read(buff);
String conffile=new String(buff);

String str1=textArea10.getText();


url = new URL ("http://127.0.0.1:7001/FileUpload?x="+str1);


urlConn = url.openConnection();

urlConn.setDoInput (true);

urlConn.setDoOutput (true);

urlConn.setUseCaches (false);
urlConn.setRequestProperty("Content-Type","multipart/form-data; boundary=-----------------------------7d11e410e500f2");

printout = new DataOutputStream (urlConn.getOutputStream ());
String preContent = "-----------------------------7d01ecf406a6\r\nContent-Disposition: form-data;name=\"upload\"; filename=\""+aa+"\"\r\nContent-Type:application/octet-stream\r\n\r\n";
String postContent = "\r\n-----------------------------7d01ecf406a6--\r\n";
printout.writeBytes(preContent);
printout.writeBytes(conffile);
printout.writeBytes(postContent);
printout.flush ();
printout.close ();
Top most Error's r like that:-
-----------------------------
C:\jdk1.2.2\bin>java ActionDemo4
Exception occurred during event dispatching:
java.lang.OutOfMemoryError
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java, Compiled Code)
at java.io.DataOutputStream.writeBytes(DataOutputStream.java:263)
Thanks for ur valuable time
Bikash

------------------
 
Bikash Paul
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Plz help me.
Regards
Bikash
------------------
 
Bikash Paul
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Plz help me.
Regards
Bikash
------------------
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
ever played with the memory options of the JVM?
for the java command in jdk 1.1.x they were:
-mxNNm (to set heap size to NN MB)
-msNNm (to set stack size to NN MB)
for java2, i'm not sure but i think they changed - have a look at the manpages!
hth
Daniel
reply
    Bookmark Topic Watch Topic
  • New Topic