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; }
}

|