MCPcopy Create free account
hub / github.com/YuLin-Coder/No830yiyongwulixue / FileToByte

Method FileToByte

src/main/java/com/utils/FileUtil.java:14–26  ·  view source on GitHub ↗
(File file)

Source from the content-addressed store, hash-verified

12
13public class FileUtil {
14 public static byte[] FileToByte(File file) throws IOException {
15 // 将数据转为流
16 @SuppressWarnings("resource")
17 InputStream content = new FileInputStream(file);
18 ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
19 byte[] buff = new byte[100];
20 int rc = 0;
21 while ((rc = content.read(buff, 0, 100)) > 0) {
22 swapStream.write(buff, 0, rc);
23 }
24 // 获得二进制数组
25 return swapStream.toByteArray();
26 }
27}

Callers 1

matchFaceMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected