Skip to content

Commit

Permalink
Update FileUtil.java
Browse files Browse the repository at this point in the history
公众号:bugstack虫洞栈 | Netty传输文件、分片发送、断点续传
  • Loading branch information
fuzhengwei committed Nov 14, 2019
1 parent 6de8415 commit 377198c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static FileBurstData readFile(String fileUrl, Integer readPosition) throw
File file = new File(fileUrl);
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r");//r: 只读模式 rw:读写模式
randomAccessFile.seek(readPosition);
byte[] bytes = new byte[1024];
byte[] bytes = new byte[1024 * 100];
int readSize = randomAccessFile.read(bytes);
if (readSize <= 0) {
randomAccessFile.close();
Expand All @@ -33,7 +33,7 @@ public static FileBurstData readFile(String fileUrl, Integer readPosition) throw
fileInfo.setBeginPos(readPosition);
fileInfo.setEndPos(readPosition + readSize);
//不足1024需要拷贝去掉空字节
if (readSize < 1024) {
if (readSize < 1024 * 100) {
byte[] copy = new byte[readSize];
System.arraycopy(bytes, 0, copy, 0, readSize);
fileInfo.setBytes(copy);
Expand Down

0 comments on commit 377198c

Please sign in to comment.