CB-4907 Close stream when we're finished with it

This commit is contained in:
Bas Bosman
2014-02-10 13:26:43 -05:00
committed by Andrew Grieve
parent d3b21b35fc
commit 6f91ac3a30
+12 -8
View File
@@ -582,15 +582,19 @@ public class FileTransfer extends CordovaPlugin {
if(err != null) if(err != null)
{ {
BufferedReader reader = new BufferedReader(new InputStreamReader(err, "UTF-8")); BufferedReader reader = new BufferedReader(new InputStreamReader(err, "UTF-8"));
String line = reader.readLine(); try {
while(line != null) String line = reader.readLine();
{ while(line != null) {
bodyBuilder.append(line); bodyBuilder.append(line);
line = reader.readLine(); line = reader.readLine();
if(line != null) if(line != null) {
bodyBuilder.append('\n'); bodyBuilder.append('\n');
}
}
body = bodyBuilder.toString();
} finally {
reader.close();
} }
body = bodyBuilder.toString();
} }
} }
// IOException can leave connection object in a bad state, so catch all exceptions. // IOException can leave connection object in a bad state, so catch all exceptions.