title: How to solve json parsing error?
body: <p>I am working on android application.I am sending Http url to the client and get back json from them. but the received json is very large so that i can't store the json values to the String. so I am getting Enlarge buffer error</p>
  
  <p>So is there any solution available to parse json value to String.I have attached My code below...</p>
  
  <pre><code>package ez.com;
  
  import java.io.DataInputStream;
  import java.io.IOException;
  import java.io.ObjectInputStream.GetField;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.net.URLConnection;
  
  import org.json.JSONArray;
  import org.json.JSONObject;
  import android.app.AlertDialog;
  import android.content.Context;
  import android.content.Intent;
  import android.text.Html;
  import android.widget.Toast;
  
  public class apiconnection {
      /** Called when the activity is first created. */
  
      public static URL                url; 
      public static URLConnection      urlConn; 
      public static DataInputStream    dis;
      public String str;
      public static int val;
  
      public static void urlconn(String url_val,Context con)
      {
          String s;
          //StringBuilder sb = new StringBuilder();
          StringBuffer sb=new StringBuffer();
          String jsonval=null;
  
          try
          {
  
              String urlval="http://iphone.openmetrics.com/apps/mattson/api.html"+url_val;
  
              System.out.println("url value for connection: " +urlval);        
              url = new URL(urlval);          
              urlConn = url.openConnection(); 
              urlConn.setDoInput(true); 
              urlConn.setUseCaches(false);
              dis = new DataInputStream(urlConn.getInputStream()); 
  
              if(dis.available()==0)
              {
                  Toast.makeText(con, "No Data found Please search another option", Toast.LENGTH_LONG).show();
                  AlertDialog.Builder ab=new AlertDialog.Builder(con);
                  ab.setMessage(Html.fromHtml("&lt;b&gt;&lt;font color=#ff0000&gt; Network Error Please try Again" +"&lt;/font&gt;&lt;/b&gt;"));
                  ab.setPositiveButton("ok", null);
                  ab.show();
  
              }
  
              while ((s = dis.readLine()) != null)
              {             
  
                  sb.append(s);
  
              }           
              "**jsonval=sb.toString();**" --------------------&gt;This line is error
              System.out.println("Json Parsed " +jsonval);
              jsonreader.json(sb.toString()); 
  
  
          }  
          catch (MalformedURLException e) 
          {
                throw new IllegalStateException("Malformed URL for : "+ e);
           }
           catch (IOException e) 
           {
                throw new IllegalStateException("IO Exception for  : " + e);
           }
  
      }
  
  }
  </code></pre>