summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Lindeberg <christian.lindeberg@sonyericsson.com>2010-11-16 09:57:54 +0100
committerJohan Redestig <johan.redestig@sonyericsson.com>2010-11-16 09:57:54 +0100
commite9f18815218b2ff1f01ea16f2eb0dd17504a9cf3 (patch)
tree9968c109bb5e96fdfe68885f9981ced61c237877
parent9de93424cc05446e3a216f406c55a3937c028416 (diff)
downloadbase-e9f18815218b2ff1f01ea16f2eb0dd17504a9cf3.tar.gz
DropBox: Read until the end of stream has been reached
Read the requested length or until the end of the input stream has actually been reached. Change-Id: I01bc0b81eca0225209bdd288dde6a778a19d1e2c
-rw-r--r--core/java/android/os/DropBoxManager.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/java/android/os/DropBoxManager.java b/core/java/android/os/DropBoxManager.java
index 7889a92286c1..4a0612cbb705 100644
--- a/core/java/android/os/DropBoxManager.java
+++ b/core/java/android/os/DropBoxManager.java
@@ -150,7 +150,12 @@ public class DropBoxManager {
try {
is = getInputStream();
byte[] buf = new byte[maxBytes];
- return new String(buf, 0, Math.max(0, is.read(buf)));
+ int readBytes = 0;
+ int n = 0;
+ while (n >= 0 && (readBytes += n) < maxBytes) {
+ n = is.read(buf, readBytes, maxBytes - readBytes);
+ }
+ return new String(buf, 0, readBytes);
} catch (IOException e) {
return null;
} finally {