程序手记

程序是我毕生的追求......
随笔 - 19, 文章 - 0, 评论 - 9, 引用 - 0
数据加载中……

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

posted on 2008-08-20 05:19 程序手记 阅读(171) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: