readtemplates.java
来自「jsp开发常用信息管理系统适合初学者学习 新闻管理」· Java 代码 · 共 57 行
JAVA
57 行
/*
* 创建日期 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 + =
减小字号Ctrl + -
显示快捷键?