private static void downloadFile(URL url, OutputStream os) throws IllegalStateException, ProtocolException, IOException {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.connect();
int responseCode = conn.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
byte tmp_buffer[] = new byte[10240];
InputStream is = conn.getInputStream();
int n;
while ((n = is.read(tmp_buffer)) > 0) {
os.write(tmp_buffer, 0, n);
os.flush();
}
} else {
throw new IllegalStateException("HTTP response: " + responseCode);
}
}
[...] bei [...] ByteArrayOutputStream.toString() wurde keine Kodierung angegeben [...]
public static String getInhalt(URL url){
String temp=null;
try {
ByteArrayOutputStream byte1 = new ByteArrayOutputStream();
byte1 = new ByteArrayOutputStream();
downloadFile(url, byte1);
temp=new String(byte1.toByteArray());//,"UTF8"); //hier also was ändern?????
byte1.close();
} catch (Exception ex) { }
return temp;
}
/* temp=new String(byte1.toByteArray()); */
temp = byte1.toString("UTF-8");
temp = new String(byte1.toByteArray(), "UTF-8");