Hej,
Det finns en finally-sats längre ner som stänger strömmarna, så det har nog inte med det att göra...
Så här ser hela metoden ut:
Kod:
private static String downloadJSON(String address) throws APIException {
InputStream is = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
try {
URL url = new URL(address);
URLConnection ucon = url.openConnection();
is = ucon.getInputStream();
bis = new BufferedInputStream(is);
dis = new DataInputStream(bis);
return dis.readLine();
} catch (Exception e) {
Log.d(TAG, "Error: " + e);
throw new APIException("Error downloading data", e);
} finally {
if (dis != null) {
try {
dis.close();
} catch (IOException e) {
Log.e(TAG, "Error closing datainputstream", e);
}
}
if (bis != null) {
try {
bis.close();
} catch (IOException e) {
Log.e(TAG, "Error closing BufferedInputStream", e);
}
}
if (is != null) {
try {
is.close();
} catch (IOException e) {
Log.e(TAG, "Error closing inputstream", e);
}
}
}
}
/Markus