支持linux下读取
import org.springframework.core.io.ClassPathResource; public byte[] getCertStream(String path) { try { ClassPathResource classPathResource = new ClassPathResource(path); //获取文件流 InputStream stream = classPathResource.getInputStream(); byte[] content = IOUtils.toByteArray(stream); stream.read(content); stream.close();
return content; } catch (IOException e) { e.printStackTrace(); } }