Skip to content

Commit 18eb917

Browse files
committed
see 09/12 log
1 parent 1eedde3 commit 18eb917

File tree

9 files changed

+254
-155
lines changed

9 files changed

+254
-155
lines changed

utilcode/src/main/java/com/blankj/utilcode/utils/ConvertUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import java.io.OutputStream;
1515
import java.io.UnsupportedEncodingException;
1616

17+
import static com.blankj.utilcode.utils.ConstUtils.KB;
18+
1719
/**
1820
* <pre>
1921
* author: Blankj
@@ -120,9 +122,9 @@ public static ByteArrayOutputStream input2OutputStream(InputStream is) {
120122
if (is == null) return null;
121123
try {
122124
ByteArrayOutputStream os = new ByteArrayOutputStream();
123-
byte[] b = new byte[ConstUtils.KB];
125+
byte[] b = new byte[KB];
124126
int len;
125-
while ((len = is.read(b)) != -1) {
127+
while ((len = is.read(b, 0, KB)) != -1) {
126128
os.write(b, 0, len);
127129
}
128130
return os;

utilcode/src/main/java/com/blankj/utilcode/utils/FileUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ public static boolean writeFileFromIS(File file, InputStream is, boolean append)
665665
os = new BufferedOutputStream(new FileOutputStream(file, append));
666666
byte data[] = new byte[KB];
667667
int len;
668-
while ((len = is.read(data)) != -1) {
668+
while ((len = is.read(data, 0, KB)) != -1) {
669669
os.write(data, 0, len);
670670
}
671671
return true;
@@ -775,7 +775,7 @@ public static int getFileLines(File file) {
775775
is = new BufferedInputStream(new FileInputStream(file));
776776
byte[] buffer = new byte[KB];
777777
int readChars;
778-
while ((readChars = is.read(buffer)) != -1) {
778+
while ((readChars = is.read(buffer, 0, KB)) != -1) {
779779
for (int i = 0; i < readChars; ++i) {
780780
if (buffer[i] == '\n') ++count;
781781
}

utilcode/src/main/java/com/blankj/utilcode/utils/ImageUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ public static String getImageType(InputStream is) {
874874
if (is == null) return null;
875875
try {
876876
byte[] bytes = new byte[8];
877-
return is.read(bytes) != -1 ? getImageType(bytes) : null;
877+
return is.read(bytes, 0, 8) != -1 ? getImageType(bytes) : null;
878878
} catch (IOException e) {
879879
e.printStackTrace();
880880
return null;

0 commit comments

Comments
 (0)