diff options
author | Christian Lindeberg <christian.lindeberg@sonyericsson.com> | 2010-11-16 09:57:54 +0100 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2010-11-18 01:54:36 -0500 |
commit | e2bb31d79c255ae3eeafab1c8293b5ac48a160ef (patch) | |
tree | a34049224d648c61e18ac4f2a0dc03a2e9df4987 /core/java | |
parent | f1c1b1d9489b0d88709b407c0f593ad83d064d1c (diff) | |
download | frameworks_base-e2bb31d79c255ae3eeafab1c8293b5ac48a160ef.zip frameworks_base-e2bb31d79c255ae3eeafab1c8293b5ac48a160ef.tar.gz frameworks_base-e2bb31d79c255ae3eeafab1c8293b5ac48a160ef.tar.bz2 |
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
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/os/DropBoxManager.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/java/android/os/DropBoxManager.java b/core/java/android/os/DropBoxManager.java index a9f9bd7..c46a42d 100644 --- a/core/java/android/os/DropBoxManager.java +++ b/core/java/android/os/DropBoxManager.java @@ -168,7 +168,12 @@ public class DropBoxManager { is = getInputStream(); if (is == null) return null; 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 { |