@author yangliyuan @version 创建时间:2024年3月28日 下午8:01:14 类说明 :
| 13 | */ |
| 14 | |
| 15 | public 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected