cn.hutool.core.io.file.FileReader Java Examples
The following examples show how to use
cn.hutool.core.io.file.FileReader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ThemeController.java From stone with GNU General Public License v3.0 | 6 votes |
/** * 获取模板文件内容 * * @param tplName 模板文件名 * * @return 模板内容 */ @GetMapping(value = "/getTpl", produces = "text/text;charset=UTF-8") @ResponseBody public String getTplContent(@RequestParam("tplName") String tplName) { String tplContent = ""; try { //获取项目根路径 final File basePath = new File(ResourceUtils.getURL("classpath:").getPath()); //获取主题路径 final StrBuilder themePath = new StrBuilder("templates/themes/"); themePath.append(BaseController.THEME); themePath.append("/"); themePath.append(tplName); final File themesPath = new File(basePath.getAbsolutePath(), themePath.toString()); final FileReader fileReader = new FileReader(themesPath); tplContent = fileReader.readString(); } catch (Exception e) { log.error("Get template file error: {}", e.getMessage()); } return tplContent; }
Example #2
Source File: ThemeController.java From blog-sharon with Apache License 2.0 | 6 votes |
/** * 获取模板文件内容 * * @param tplName 模板文件名 * @return 模板内容 */ @GetMapping(value = "/getTpl", produces = "text/text;charset=UTF-8") @ResponseBody public String getTplContent(@RequestParam("tplName") String tplName) { String tplContent = ""; try { //获取项目根路径 File basePath = new File(ResourceUtils.getURL("classpath:").getPath()); //获取主题路径 File themesPath = new File(basePath.getAbsolutePath(), new StringBuffer("templates/themes/").append(BaseController.THEME).append("/").append(tplName).toString()); FileReader fileReader = new FileReader(themesPath); tplContent = fileReader.readString(); } catch (Exception e) { log.error("Get template file error: {}", e.getMessage()); } return tplContent; }
Example #3
Source File: DocumentBrowser.java From book118-downloader with MIT License | 5 votes |
List<String> readTaskList() { List<String> aTaskDocumentId = new ArrayList<>(); if (FileUtil.exist(TASK_LIST_FILE)) { FileReader fileReader = new FileReader(TASK_LIST_FILE); aTaskDocumentId = fileReader.readLines().stream() .map(StrUtil::trim).filter(StrUtil::isNotBlank).collect(Collectors.toList()); } return aTaskDocumentId; }
Example #4
Source File: DocumentBrowser.java From book118-downloader with MIT License | 5 votes |
private int readDownloadedPage(String sDocumentId) { int nPage = 1; String filePath = String.format(FILE_DOWNLOAD_PAGE, sDocumentId); if (FileUtil.exist(filePath)) { FileReader fileReader = new FileReader(filePath); String sPage = fileReader.readString(); nPage = Integer.valueOf(sPage); } return nPage; }
Example #5
Source File: AdminServiceImpl.java From halo with GNU General Public License v3.0 | 5 votes |
@Override public String getApplicationConfig() { File file = new File(haloProperties.getWorkDir(), APPLICATION_CONFIG_NAME); if (!file.exists()) { return StringUtils.EMPTY; } FileReader reader = new FileReader(file); return reader.readString(); }