2011-05-24 172 views
0
public final class MyScreen extends MainScreen { 
    /** 
    * Creates a new MyScreen object 
    */ 
    public MyScreen() { 
     MyScreen myScreen = new MyScreen(); 
     String a = myScreen.getPage("http://www.google.com"); 
     System.out.println("+++ " + a); 
    } 

    public void parse(String xml) { 
    } 

    public String getPage(String url) { 
     String response = ""; 

     try { 
      StreamConnection s = (StreamConnection) Connector.open(url); 
      InputStream input = s.openInputStream(); 

      byte[] data = new byte[256]; 
      int len = 0; 
      StringBuffer raw = new StringBuffer(); 

      while (-1 != (len = input.read(data))) { 
       raw.append(new String(data, 0, len)); 
      } 

      response = raw.toString(); 

      input.close(); 
      s.close(); 
     } catch (Exception e) {} 

     return response; 
    } 
} 

當我在我的黑莓模擬器中執行此程序時,出現StackOverflow錯誤。黑莓HTTP連接

我該如何解決這個問題?

回答