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 错误。

我该如何解决这个问题?

4

1 回答 1

1

结帐:

1)。黑莓真机上的Http连接错误

2)。http://docs.blackberry.com/en/developers/deliverables/11938/CS_create_first_available_HTTP_connection_857706_11.jsp

这可能会对您有所帮助。

于 2011-05-24T05:03:00.893 回答