Skip to content

Commit 3479795

Browse files
committed
see 09/13 log
1 parent aba4264 commit 3479795

File tree

6 files changed

+714
-274
lines changed

6 files changed

+714
-274
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public class ConvertUtils {
3737
* @return 16进制大写字符串
3838
*/
3939
public static String bytes2HexString(byte[] bytes) {
40-
char[] res = new char[bytes.length << 1];
40+
char[] ret = new char[bytes.length << 1];
4141
for (int i = 0, j = 0; i < bytes.length; i++) {
42-
res[j++] = hexDigits[bytes[i] >>> 4 & 0x0f];
43-
res[j++] = hexDigits[bytes[i] & 0x0f];
42+
ret[j++] = hexDigits[bytes[i] >>> 4 & 0x0f];
43+
ret[j++] = hexDigits[bytes[i] & 0x0f];
4444
}
45-
return new String(res);
45+
return new String(ret);
4646
}
4747

4848
/**
@@ -59,11 +59,11 @@ public static byte[] hexString2Bytes(String hexString) {
5959
throw new IllegalArgumentException("长度不是偶数");
6060
}
6161
char[] hexBytes = hexString.toUpperCase().toCharArray();
62-
byte[] res = new byte[len >>> 1];
62+
byte[] ret = new byte[len >>> 1];
6363
for (int i = 0; i < len; i += 2) {
64-
res[i >> 1] = (byte) (hex2Dec(hexBytes[i]) << 4 | hex2Dec(hexBytes[i + 1]));
64+
ret[i >> 1] = (byte) (hex2Dec(hexBytes[i]) << 4 | hex2Dec(hexBytes[i + 1]));
6565
}
66-
return res;
66+
return ret;
6767
}
6868

6969
/**
@@ -308,12 +308,12 @@ public static Bitmap drawable2Bitmap(Drawable drawable) {
308308
/**
309309
* bitmap转drawable
310310
*
311-
* @param resources resources对象
312-
* @param bitmap bitmap对象
311+
* @param res resources对象
312+
* @param bitmap bitmap对象
313313
* @return drawable对象
314314
*/
315-
public static Drawable bitmap2Drawable(Resources resources, Bitmap bitmap) {
316-
return bitmap == null ? null : new BitmapDrawable(resources, bitmap);
315+
public static Drawable bitmap2Drawable(Resources res, Bitmap bitmap) {
316+
return bitmap == null ? null : new BitmapDrawable(res, bitmap);
317317
}
318318

319319
/**
@@ -330,12 +330,12 @@ public static byte[] drawable2Bytes(Drawable drawable, Bitmap.CompressFormat for
330330
/**
331331
* byteArr转drawable
332332
*
333-
* @param resources resources对象
334-
* @param bytes 字节数组
333+
* @param res resources对象
334+
* @param bytes 字节数组
335335
* @return drawable对象
336336
*/
337-
public static Drawable bytes2Drawable(Resources resources, byte[] bytes) {
338-
return bitmap2Drawable(resources, bytes2Bitmap(bytes));
337+
public static Drawable bytes2Drawable(Resources res, byte[] bytes) {
338+
return bitmap2Drawable(res, bytes2Bitmap(bytes));
339339
}
340340

341341
/**

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,23 +319,18 @@ public static String encryptMD5File2String(File file) {
319319
* @return 文件的MD5校验码
320320
*/
321321
public static byte[] encryptMD5File(File file) {
322-
FileInputStream in = null;
322+
FileInputStream fis = null;
323323
try {
324-
in = new FileInputStream(file);
325-
FileChannel channel = in.getChannel();
324+
fis = new FileInputStream(file);
325+
FileChannel channel = fis.getChannel();
326326
MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, file.length());
327327
MessageDigest md = MessageDigest.getInstance("MD5");
328328
md.update(buffer);
329329
return md.digest();
330330
} catch (NoSuchAlgorithmException | IOException e) {
331331
e.printStackTrace();
332332
} finally {
333-
if (in != null) {
334-
try {
335-
in.close();
336-
} catch (IOException ignored) {
337-
}
338-
}
333+
FileUtils.closeIO(fis);
339334
}
340335
return null;
341336
}

0 commit comments

Comments
 (0)