public static String readURL(URLConnection in) {
try {
- if ( !in.getContentType().equals("text/html; charset=UTF-8")) {
+ if ( !in.getContentType().equals("text/html; charset=UTF-8") && !in.getContentType().equals("text/plain; charset=UTF-8")) {
if (in instanceof HttpURLConnection && ((HttpURLConnection) in).getResponseCode() != 200) {
System.err.println(readURL(new InputStreamReader(((HttpURLConnection) in).getErrorStream(), "UTF-8")));
}
while ((len = in.read(buffer)) > 0) {
caw.write(buffer, 0, len);
}
+ in.close();
return new String(caw.toCharArray());
} catch (IOException e) {
throw new Error(e);
while ((len = in.read(buffer)) > 0) {
baos.write(buffer, 0, len);
}
+ in.close();
return baos.toByteArray();
} catch (IOException e) {
throw new Error(e);