JSONの中身をURL型のurlという変数に格納して、その中身を見たいのですが「String.valueOf」を使いデバックモードでブレークポイントを設定すれば変数の中身が見れると思うのですがコンソールに何も現れないのですが何か対処法御座いましたらご教授願います。
状況
URL url = new URL("http://www.ekidata.jp/api/l/11302.json");で
URL型の変数urlにJSONデータサイトを格納している。
環境
アンドロイドスタジオ2.3
Java
JSONObject json = new JSONObject(String.valueOf(url));を使い
変数url格納したJSONデータをコンソール上で確認したい。
その為にはデバッグモードを使いブレークポイントを設定すれば見られるのではないか?と考えているがコンソール上に反映されない。
TestService.java
package jp.co.mocosuku.phr.service;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class TestService {
public static void executeGet(){
// ...
SubThread sub = new SubThread();
sub.start();
}
}
class SubThread extends Thread{
public void run(){
// executeGet() の中身をここに移動させる
System.out.println("===== HTTP GET Start =====");
try {
URL url = new URL("http://www.ekidata.jp/api/l/11302.json");
HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
JSONObject json = new JSONObject(String.valueOf(url));
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
try (InputStreamReader isr = new InputStreamReader(connection.getInputStream(),
StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(isr)) {
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}
}
} finally {
if (connection != null) {
connection.disconnect();
}
}
} catch (JSONException e) {
e.printStackTrace();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("===== HTTP GET End =====");
}
}
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・14歳の自分に衝撃の事実を告げてください
- ・架空の映画のネタバレレビュー
- ・「お昼の放送」の思い出
- ・昨日見た夢を教えて下さい
- ・【お題】絵本のタイトル
- ・【大喜利】世界最古のコンビニについて知ってる事を教えてください【投稿~10/10(木)】
- ・メモのコツを教えてください!
- ・CDの保有枚数を教えてください
- ・ホテルを選ぶとき、これだけは譲れない条件TOP3は?
- ・家・車以外で、人生で一番奮発した買い物
- ・人生最悪の忘れ物
- ・【コナン30周年】嘘でしょ!?と思った○○周年を教えて【ハルヒ20周年】
- ・ハマっている「お菓子」を教えて!
- ・最近、いつ泣きましたか?
- ・夏が終わったと感じる瞬間って、どんな時?
- ・10秒目をつむったら…
- ・人生のプチ美学を教えてください!!
- ・あなたの習慣について教えてください!!
- ・牛、豚、鶏、どれか一つ食べられなくなるとしたら?
- ・都道府県穴埋めゲーム
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
<forEach> 内で供給された "ite...
-
eclipseに記述したjavaファイル...
-
importするには java.io.*; imp...
-
アルファベットのソート
-
「例外 *** は対応する try 文...
-
日数計算の方法
-
CSV読み込み 文字化け
-
メニューバーのプログラム
-
jcpad
-
干支の計算で。。。
-
Path型をString型へ変換する(Java)
-
ORA-01858: 数値を指定する箇所...
-
C言語のポインターに関する警告
-
[JAVA]try 内の変数を外で!?
-
Javaで改行などが出来ないのです。
-
System.err. printlnとSystem.o...
-
変数を動的に利用するには?
-
パソコンキーボードで時分秒を...
-
オブジェクトの中のプロパティ...
-
論理演算子”||”またはの入力方法
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
eclipseに記述したjavaファイル...
-
importするには java.io.*; imp...
-
<forEach> 内で供給された "ite...
-
「例外 *** は対応する try 文...
-
java.util.Comparatorのcompare...
-
ColabでのPytorchのエラー
-
正規表現について
-
JAVAサーブレット。 HTML...
-
ActionForm form にnullが入っ...
-
Selenium IDEでexportしたコー...
-
ファイル名を動的に生成したい
-
【java】検索フォームの検索結...
-
setAttribute(String, int)は適...
-
シャットダウンフックが呼ばれない
-
do while文のエラー??
-
JPEG画像のみを印刷したいので...
-
サーバーAからサーバーBへPOST...
-
メニューバーのプログラム
-
アプレットを実行すると、×が表...
-
JOGLのインストール方法
おすすめ情報