Web サイト (URL: http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player=Hydro698 ) からすべてのテキストを取得し、複数行ではなく単一行の文字列に入れるにはどうすればよいですか? 、現在、約20行のギブまたはテイクがありますが、1行にしたいです。
テキストを取得するためのコード:
public static void getTextFromURL() {
URL url;
InputStream is = null;
BufferedReader br;
String line;
try {
url = new URL("http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player=Hydro698");
is = url.openStream(); // throws an IOException
br = new BufferedReader(new InputStreamReader(is));
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
is.close();
} catch (IOException ioe) {
// nothing to see here
}
}
}
編集:すべてのコードを提供する必要はありません。正しい方向へのポイントだけです。:)