readtemplates.java
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;
}
}
