最简单的,我喜欢
在一个jsp文件中取出要打印的10条记录
tomcat/conf/web.xml下加:
<mime-mapping> 
<extension>xls</extension> 
<mime-type>application/msexcel</mime-type> 
</mime-mapping>
需要导出的文件头上加:
<%@ page contentType="application/vnd.ms-excel" %>

解决方案 »

  1.   

    我的想法:
    将文件中的每一行作为一个string入栈,然后出栈读取即可。
      

  2.   

    给出我的答案,大家参考一下:
    希望大家给出源代码,,,,,谢谢,,,,,import java.io.*;
    class Tail{
      public static void main(String[] args)throws IOException{
            if(args.length!=1){
             System.err.println("请指定一个文件名");
             System.exit(1);
            }
            int num=0;
            String s=null;
            BufferedReader br=null,b=null;
       try{br=new BufferedReader(new FileReader(args[0]));}
       catch(FileNotFoundException e){
       System.err.println("系统找不到指定的文件"+args[0]);
       }
       finally{if (br==null) {System.exit(1);}}
            while(br.readLine()!=null){
             num++;
            }
            if(num>=10){
             b=new BufferedReader(new FileReader(args[0]));
             for(int i=0;i<num;i++){
             if(i>=num-10){
             System.out.println(b.readLine());
             }
             else b.readLine();
             }
            }
            else System.err.println("指定文件"+args[0]+"不足十行");
      }
    }