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

📄 readtemplates.java

📁 一个用jsp技术实现的新闻发布系统
💻 JAVA
字号:
package net.ijsp.news.news;

/**
*  Title  读取模板配置信息
*  @author: ccjsmile
*  Company: http://www.ijsp.net
*  Copyright: Copyright (c) 2003
*  @version 1.0 beta
*/

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

public class ReadTemplates {
	
	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(String fileName) throws ReadTemplateException {
		if(templateContent==null) {
			synchronized(lock) {
				if(templateContent==null)
					try{
					System.out.println("+++++++++++++");
						templateContent = readTemplate(fileName);
					}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;
	}
	
}

⌨️ 快捷键说明

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