jsp读取*.TXT

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() %>

你可能感兴趣的:(jsp读取*.TXT)