www.pudn.com > 200402121144312230.rar > ReadTemplate.java


package net.ijsp.news.news;

/**
 * 

Title: 读取模板配置信息

*

Description:

*

Copyright: Copyright (c) 2003

*

Company:ijsp.net

* @author ccjsmile * @version 1.0 */ import java.io.FileInputStream; import java.io.IOException; public class ReadTemplate { private static String templateContent = null; // 模板内容 // private static String fileName = null; // 模板文件名 private static Object lock = new Object(); // private String pathFile = ""; /** * 获取模板基本配置信息 * @return String * @throws ReadTemplateException */ public static String getTlpContent() throws ReadTemplateException { /* if(templateContent==null) { synchronized(lock) { if(templateContent==null) try{ System.out.println("+++++++++++++"); templateContent = readTemplate(pathFile); }catch(ReadTemplateException r) { throw new ReadTemplateException("模板信息读取失败。"); } } } */ return templateContent; } /** * 读取文件内容 * @return String * @throws ReadTemplateException */ private synchronized static String readTemplate(String pathFile) throws ReadTemplateException { String templateContent = null; /** try{ FileInputStream fis = new FileInputStream(pathFile); int fileLength = fis.available(); byte template[] = new byte[fileLength]; fis.read(template); fis.close(); templateContent = new String(template); }catch(IOException ie){ throw new ReadTemplateException(); } */ return templateContent; } }