⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readtemplates.java

📁 jsp开发常用信息管理系统适合初学者学习 新闻管理
💻 JAVA
字号:
/*
 * 创建日期 2007-3-13
 */
package ch06.html.utils;

import java.io.FileInputStream;
import java.io.IOException;

/**
 * @author <a href="chengweits@hotmail.com">ChengWei </a>
 *  读取摸版的封装
 */
public class ReadTemplates {

    private static String _fldif = null;

    private static Object a = new Object();

    //构造函数
    public ReadTemplates() {
    }

    //获取模版内容
    public static String getTlpContent(String s) throws ReadTemplateException {
        if (_fldif == null)
            synchronized (a) {
                if (_fldif == null)
                    try {
                        System.out.println("+++++++++++++"+s);
                        _fldif = read(s);
                    } catch (ReadTemplateException readtemplateexception) {
                        throw new ReadTemplateException("模板信息读取失败。");
                    }
            }
        return _fldif;
    }
    /**
     * 读取响应的内容
     * @param name
     * @return
     * @throws ReadTemplateException
     */
    private static synchronized String read(String name) throws ReadTemplateException {
        String s1 = null;
        try {
            FileInputStream fileinputstream = new FileInputStream(name);
            int i = fileinputstream.available();
            byte abyte0[] = new byte[i];
            fileinputstream.read(abyte0);
            fileinputstream.close();
            s1 = new String(abyte0);
        } catch (IOException ioexception) {
            throw new ReadTemplateException();
        }
        return s1;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -