jsp生成html--readtemplates

发表于:2007-07-04来源:作者:点击数: 标签:
package ball.news; import java .io.*; import java.util.*; public class ReadTemplates { private String temp = null; private Object a = new Object(); public ReadTemplates() { } public String getTlpContent(String s) { if(temp == null) synchro


package ball.news;
import java.io.*;
import java.util.*;

public class ReadTemplates
{

private String temp = null;
private Object a = new Object();

public ReadTemplates()
{
}

public String getTlpContent(String s)

{
if(temp == null)
synchronized(a)
{
if(temp == null)
try
{
System.out.println("----------------------------");
temp = a(s);
//System.out.println("test the temp"+temp);
}
catch(Exception e)
{
System.out.println("get tlpconente error"+e.getMessage());
}
}
return temp;
}

private synchronized String a(String s)

{
String s1 = null;
try
{
FileInputStream fileinputstream = new FileInputStream(s);
int i = fileinputstream.available();
byte abyte0[] = new byte[i];
fileinputstream.read(abyte0);
fileinputstream.close();
s1 = new String(abyte0);
}
catch(IOException e)
{
System.out.println("ioexception error"+e.getMessage());
}
return s1;
}

}


原文转自:http://www.ltesting.net