Commit 93dd46ff authored by luzhuang's avatar luzhuang

修改

parent d85f3c1f
......@@ -25,16 +25,16 @@ public class CheckFileHeaderUtil {
* @param url
* @return
*/
public boolean toCheck(String url){
public static boolean toCheck(String url){
String result = "";
try{
FileInputStream is = new FileInputStream(url);
byte[] b = new byte[45];
is.read(b, 0, b.length);
result = this.checkType(bytesToHexString(b).toUpperCase());
result = checkType(bytesToHexString(b).toUpperCase());
is.close();
}catch (Exception e){
log.debug(e.getMessage());
log.error(e.getMessage());
}
if(result.toUpperCase().contains(url.substring(url.lastIndexOf(".")+1).toUpperCase())){
return true;
......
......@@ -84,6 +84,11 @@ public class FileReadableUtil {
}catch(Exception e){
log.error("关闭 InputStream 输出流错误!", e);
}
if (!CheckFileHeaderUtil.toCheck(path)){
throw new ServiceException(ResultServiceEnums.FILE_UNREADABLE);
}
}
public File TXTHandler(File file) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment