一次性读取全部文件数据 @param strFile
(String strFile)
| 19 | * @param strFile |
| 20 | */ |
| 21 | public static void readFile(String strFile) { |
| 22 | try { |
| 23 | InputStream is = new FileInputStream(strFile); |
| 24 | int iAvail = is.available(); |
| 25 | byte[] bytes = new byte[iAvail]; |
| 26 | is.read(bytes); |
| 27 | log.info("文件内容:\n" + new String(bytes)); |
| 28 | is.close(); |
| 29 | } catch (Exception e) { |
| 30 | e.printStackTrace(); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * 按行读取文件 |