读取指定路径的文件。 @return fileContentStr
(String filePath)
| 23 | * @return fileContentStr |
| 24 | */ |
| 25 | public static String readFile(String filePath) { |
| 26 | String fileContentStr = null; |
| 27 | try { |
| 28 | InputStream inputStream = new FileInputStream(filePath); |
| 29 | int size = inputStream.available(); |
| 30 | byte[] buffer = new byte[size]; |
| 31 | inputStream.read(buffer); |
| 32 | inputStream.close(); |
| 33 | fileContentStr = new String(buffer, StandardCharsets.UTF_8); |
| 34 | } catch (FileNotFoundException e) { |
| 35 | log.debug("file not found", e); |
| 36 | } catch (IOException e) { |
| 37 | log.warn("", e); |
| 38 | } |
| 39 | return fileContentStr; |
| 40 | } |
| 41 | |
| 42 | |
| 43 | /** |