GAL-224 DoS检测支持知识库动态加载
This commit is contained in:
24
src/main/java/com/zdjizhi/utils/FileByteUtils.java
Normal file
24
src/main/java/com/zdjizhi/utils/FileByteUtils.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.zdjizhi.utils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class FileByteUtils {
|
||||
|
||||
public static byte[] getFileBytes (String filePath) throws IOException {
|
||||
File file = new File(filePath);
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
|
||||
byte[] b = new byte[1024];
|
||||
int n;
|
||||
while ((n = fis.read(b)) != -1) {
|
||||
bos.write(b, 0, n);
|
||||
}
|
||||
fis.close();
|
||||
byte[] data = bos.toByteArray();
|
||||
bos.close();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user