解决方案 »

  1.   

    这个读取文件网上一搜就一堆现成的,并且你发错版块了,要发到java web开发去。
      

  2.   

    xx.txt如果是在客户端 不上传直接读 那最好别想了 html5的file api倒是可以 但不是所有浏览器都支持 而且不能你指定路径 ie貌似有对应的乱七八槽的功能  但最好放弃
    如果是在服务器端的话  ajax试试  
      

  3.   


    <%
    String path="E:\\FILE";  //目录分隔符必须用双斜杠
    File file=new File(path,"jsp.txt");
    FileReader fr=new FileReader(file);   //字符输入流
    BufferedReader br=new BufferedReader(fr);   //使文件可按行读取并具有缓冲功能
    StringBuffer strB=new StringBuffer();  //strB用来存储jsp.txt文件里的内容
    String str=br.readLine();
    while(str!=null){
     //out.println(str);
     strB.append(str).append("<br>");    //将读取的内容放入strB
     str=br.readLine();
    }
    br.close();            //关闭输入流
    fr.close();
    %>
    <%=strB  %>