This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT 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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "java.lang.OutOfMemoryError" Watch "java.lang.OutOfMemoryError" New topic
Author

java.lang.OutOfMemoryError

Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
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

Joined: Dec 04, 2001
Posts: 342
Hi,
Plz help me.
Regards
Bikash
------------------
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi,
Plz help me.
Regards
Bikash
------------------
Daniel Brugger
Greenhorn

Joined: Dec 13, 2001
Posts: 5
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.lang.OutOfMemoryError