读文件 @param path 路径 @param encoding 编码 UTF-8 @return 文本字符串
(String path,String encoding)
| 94 | * @return 文本字符串 |
| 95 | */ |
| 96 | public static String readFileToString(String path,String encoding){ |
| 97 | |
| 98 | try { |
| 99 | File file = new File(PathUtil.defaultExternalDirectory()+File.separator+path); |
| 100 | if(file.exists()){ |
| 101 | return FileUtils.readFileToString(file, encoding); |
| 102 | } |
| 103 | |
| 104 | } catch (IOException e) { |
| 105 | // TODO Auto-generated catch block |
| 106 | // e.printStackTrace(); |
| 107 | if (logger.isErrorEnabled()) { |
| 108 | logger.error("读文件",e); |
| 109 | } |
| 110 | } |
| 111 | return null; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * 读文件(读取的内容不包含UTF-8 BOM标志) |
no test coverage detected