MCPcopy Create free account
hub / github.com/LisenCoding/cangku / FileUtil

Class FileUtil

boot/src/main/java/com/utils/FileUtil.java:15–29  ·  view source on GitHub ↗

@author yangliyuan @version 创建时间:2024年3月28日 下午8:01:14 类说明 :

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected