JSP基础 (高级计数器实例) 第二十天

JSP基础 (高级计数器实例) 第二十天

                                                                           countFile.java
public class countFile{
    public static void writeFile(String filename,long count){
        PrintWriter out = new PrintWriter(new FileWriter(filename));
        out.println(count);
        out.close();
    }
    public static void readFile(String filename){
        File f = new File(filename);
        if(!f.exists()){
            writeFile(filename,0);
        }
        BufferedReader in = new BufferedReader(new FileReader(f));
        long count = Long.parseLong(in.readline());
        return count;
    }
    public static String tranform(long count){
        String countNumber = ""+count;
        String newstring = "";
        for(int i=0;i<countNumber.length;i++){
            newstring+="<img src='images/"+countNumber.charAT(i)+".gif' >";
        }
        return newstring;
    }
}



你可能感兴趣的:(JSP基础 (高级计数器实例) 第二十天)