Skip to content

Commit 383e95e

Browse files
bradfitzAndroid Code Review
authored andcommitted
Merge "DropBox: Read until the end of stream has been reached"
2 parents db65907 + e9f1881 commit 383e95e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/java/android/os/DropBoxManager.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,12 @@ public String getText(int maxBytes) {
150150
try {
151151
is = getInputStream();
152152
byte[] buf = new byte[maxBytes];
153-
return new String(buf, 0, Math.max(0, is.read(buf)));
153+
int readBytes = 0;
154+
int n = 0;
155+
while (n >= 0 && (readBytes += n) < maxBytes) {
156+
n = is.read(buf, readBytes, maxBytes - readBytes);
157+
}
158+
return new String(buf, 0, readBytes);
154159
} catch (IOException e) {
155160
return null;
156161
} finally {

0 commit comments

Comments
 (0)