Skip to content

Commit 53695ce

Browse files
author
YangSen-qn
committed
modify uplog read logic
1 parent 28f4d3e commit 53695ce

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

library/src/main/java/com/qiniu/android/collect/UploadInfoCollector.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.qiniu.android.storage.UpToken;
55
import com.qiniu.android.utils.GZipUtil;
66

7+
import java.io.ByteArrayOutputStream;
78
import java.io.File;
89
import java.io.FileNotFoundException;
910
import java.io.FileOutputStream;
@@ -286,13 +287,17 @@ private byte[] getLogData(File recordFile){
286287
return null;
287288
}
288289

289-
long length = recordFile.length();
290290
RandomAccessFile randomAccessFile = null;
291291
byte[] data = null;
292292
try {
293293
randomAccessFile = new RandomAccessFile(recordFile, "r");
294-
data = new byte[(int)length];
295-
randomAccessFile.read(data);
294+
ByteArrayOutputStream out = new ByteArrayOutputStream();
295+
int len = 0;
296+
byte[] buff = new byte[3096];
297+
while ((len = randomAccessFile.read(buff)) >= 0){
298+
out.write(buff, 0, len);
299+
}
300+
data = out.toByteArray();
296301
} catch (FileNotFoundException ignored) {
297302
} catch (IOException e) {
298303
data = null;

0 commit comments

Comments
 (0)