Java Code Examples for cn.hutool.core.io.file.FileReader#readString()

The following examples show how to use cn.hutool.core.io.file.FileReader#readString() . 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 vote down vote up
/**
 * 获取模板文件内容
 *
 * @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 vote down vote up
/**
 * 获取模板文件内容
 *
 * @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 vote down vote up
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 4
Source File: AdminServiceImpl.java    From halo with GNU General Public License v3.0 5 votes vote down vote up
@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();
}