Guten Tag,
ich bin neu hier im Forum und ich hoffe ihr könnt mir helfen: Seit nun mehreren Stunden versuche ich verzweifelt den Inhalt der Seite http://mcpvp.com/api/ping.json herunterzuladen. Das Problem ist, dass ich immer irgendwelche Hyroglyphen herausbekomme, die ich natürlich in nach JSON decoden kann. Ich habe bereits alle, mir bekannten, charsets ausprobiert, es aber immer noch nicht geschafft.
Das ist mein bisheriger Ansatz:
Utils Klasse (ausschnitt):
public class Utils {
public static String download(String path) throws IOException {
InputStream s = null;
String content = null;
try {
s = (InputStream)new URL(path).getContent();
content = IOUtils.toString(s, "UTF-8");
}
finally {
if (s != null) s.close();
}
if (content == null) return null;
return content.toString();
}
}
ich bin neu hier im Forum und ich hoffe ihr könnt mir helfen: Seit nun mehreren Stunden versuche ich verzweifelt den Inhalt der Seite http://mcpvp.com/api/ping.json herunterzuladen. Das Problem ist, dass ich immer irgendwelche Hyroglyphen herausbekomme, die ich natürlich in nach JSON decoden kann. Ich habe bereits alle, mir bekannten, charsets ausprobiert, es aber immer noch nicht geschafft.
Das ist mein bisheriger Ansatz:
Java:
String text = new String(Utils.download("http://mcpvp.com/api/ping.json").getBytes(), "Iso-8859-1");
Utils Klasse (ausschnitt):
public class Utils {
public static String download(String path) throws IOException {
InputStream s = null;
String content = null;
try {
s = (InputStream)new URL(path).getContent();
content = IOUtils.toString(s, "UTF-8");
}
finally {
if (s != null) s.close();
}
if (content == null) return null;
return content.toString();
}
}
Java:
Mfg LuAl