java技术博客

jsp博客
数据加载中……
jsp读取*.TXT
package mypack;
import java.io.*;

public class ReadText{
    
public String getShiGe(){
        
//File f=new File("guoxinghua.txt");
        File f=new File(this.getClass().getResource("guoxinghua.txt").toURI());
        
try{
            FileReader fr
=new FileReader(f);
            BufferedReader buff
=new BufferedReader(fr);//BufferedReader用于读取文本
            String line="";
            
while((line=buff.readLine())!=null)
            
{
                retstr
+line+"<br>";
                }

                buff.close();
                }

            
catch(Exception e)
            
{
                e.printStackTrace();
                
                }

                
                
                
return retstr;
                }

    }



<%@page language="java" import="java.util.*,mypack" page Encoding="GBK"%>
<%
ReadText rt
=new ReadText();
%>
<%=rt.getShiGe()%>

posted on 2008-10-26 07:20 郭兴华 阅读(752) 评论(1)  编辑  收藏

评论

# re: jsp读取*.TXT 2009-04-28 16:06 jsp

请问 retstr是什么数据类型?String?好像不行哦
  回复  更多评论    

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


网站导航: