1
我製作了一個使用LWUIT IO庫進行http請求的方法,並嘗試使用J2me庫。一切都在模擬器上正常工作,但當我厭倦了兩個不同的諾基亞手機,然後我收到異常。兩者都顯示了不同的例外。 者除外使用LWUIT IO和J2me庫進行http請求時出現異常
- 411長度所需
- 產生java.io.IOException:錯誤HTTP操作:在HTTP操作錯誤
這裏是我的代碼 -
private void startReq(String url) {
NetworkManager.getInstance().start();
ConnectionRequest myRequest = new ConnectionRequest() {
protected void readResponse(InputStream input) throws IOException {
StringBuffer stringBuffer = new StringBuffer();
int ch;
while ((ch = input.read()) != -1) {
stringBuffer.append((char) ch);
}
System.out.println("Response:"+stringBuffer.toString());
}
};
progress = new Progress("Please Wait ", myRequest,true);
progress.setDisposeOnCompletion(true);
myRequest.setUrl(url);
myRequest.setPost(true);
NetworkManager.getInstance().addToQueue(myRequest);
progress.show();
}