これがこのコードの私のコードです。try ブロック内の値はhttpconn = nullの値を取得していますが、最初の行で変数httpconnに値を格納しています。nullpointerexceptionが発生しています。
public static String requestToken() { 文字列 url = Const.REQUEST_TOKEN_URL; 文字列ヘッダー = oauth_header(url, HttpProtocolConstants.HTTP_METHOD_GET); 文字列 requestTokenUrl = concatURL(url, ヘッダー); HttpConnection httpConn = null; InputStream 入力 = null; 試す { httpConn = (HttpConnection) Connector.open(requestTokenUrl); //クリス接続 httpConn.setRequestMethod(HttpProtocolConstants.HTTP_METHOD_GET); httpConn.setRequestProperty("WWW-Authenticate","OAuth realm=http://twitter.com/"); httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 入力 = httpConn.openDataInputStream(); int resp = httpConn.getResponseCode(); if (resp == HttpConnection.HTTP_OK) { StringBuffer バッファ = 新しい StringBuffer(); int ch; while ( (ch = input.read()) != -1) { buffer.append( (char) ch); } 文字列の内容 = buffer.toString(); Const.token = content.substring(content.indexOf((Const.OAUTH_TOKEN+"="))+(Const.OAUTH_TOKEN+"=").length(), content.indexOf('&')); Const.tokenSecret = content.substring(content.indexOf((Const.OAUTH_TOKEN_SECRET+"="))+(Const.OAUTH_TOKEN_SECRET+"=").length(), content.length()); メッセージ = httpConn.getResponseMessage(); } メッセージを返す;//(getTwitterMessage(httpConn.getResponseCode())); } キャッチ (IOException e) { 「例外」を返します。 } キャッチ (例外 nc) { 「接続なし」を返します。 } 最後に { 試す { httpConn.close(); 入力.close(); } キャッチ (IOException e) { e.printStackTrace(); }