package com.qianwen.smartman.modules.dnc.util; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.List; import javax.validation.constraints.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class FileUtils { private static final Logger log = LoggerFactory.getLogger(FileUtils.class); public static boolean hasSpecial(@NotNull String fileName) { char[] chars = fileName.toCharArray(); List list = Arrays.asList(34, 42, 47, 58, 60, 62, 63, 92, 124); for (char c : chars) { if (list.contains(Integer.valueOf(c))) { return true; } } return false; } public static byte[] inputStream2byte(InputStream inputStream) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] bytes = new byte[100]; while (true) { try { try { int rc = inputStream.read(bytes, 0, 100); if (rc <= 0) { break; } byteArrayOutputStream.write(bytes, 0, rc); } catch (Throwable th) { try { byteArrayOutputStream.close(); } catch (IOException e) { log.error(e.getMessage()); } throw th; } } catch (IOException e2) { log.error(e2.getMessage()); try { byteArrayOutputStream.close(); } catch (IOException e3) { log.error(e3.getMessage()); } } } bytes = byteArrayOutputStream.toByteArray(); try { byteArrayOutputStream.close(); } catch (IOException e4) { log.error(e4.getMessage()); } return bytes; } }