So I'm trying to pass a very large string (~15mb) as a parameter using httppost but I'm getting an OutOfMemoryException. The heap size is set to 512-1024mb (which should be more than enough.)
Is there a way around this problem? I'd appreciate any help. Here's the code: ---------------------------------------------------------------------------------- HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://xxxx/xxx"); // read file into string byte[] buffer = new byte[(int) new File(filePathName).length()]; BufferedInputStream f = new BufferedInputStream(new FileInputStream(filePathName)); f.read(buffer); String str = new String(buffer); // create name value pairs for post List <NameValuePair> nvps = new ArrayList <NameValuePair>(); nvps.add(new BasicNameValuePair("A", "en")); nvps.add(new BasicNameValuePair("B", "1")); nvps.add(new BasicNameValuePair("C", str)); httppost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); // throws the exception System.out.println("executing request " + httppost.getURI()); // Create a response handler ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httppost, responseHandler); System.out.println(responseBody); httpclient.getConnectionManager().shutdown(); ------------------------------------------------------------------------------ -- View this message in context: http://old.nabble.com/UrlEncodedFormEntity-throws-OutOfMemoryError-exception-tp27244948p27244948.html Sent from the HttpClient-User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org