是否用FileInputStream和FileOutputStream实现

解决方案 »

  1.   

    先读取文件,然后通过poi包里的   
    HSSFWorkbook的对象名.write(要考到的文件);
    就可以了.
      

  2.   

    不管什么类型的文件,都可以用FileInputStream和FileOutputStream进行拷贝。import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;public class FileCopy {    public static <T> void main(String[] args) throws Exception {
            FileInputStream fis = new FileInputStream(new File("d:\\test.xls"));
            FileOutputStream fos = new FileOutputStream(new File("e:\\test.xls"));
            byte[] buff = new byte[1024];
            int len = 0;
            try {
                len = fis.read(buff);
                while (len > 0) {
                    fos.write(buff, 0, len);
                    len = fis.read(buff);
                }
            } finally {
                fis.close();
                fos.close();
            }
        }
    }
      

  3.   

    告诉你一个高效的实现,用NIO,传统的IO速度慢
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.nio.MappedByteBuffer;
    import java.nio.channels.FileChannel;public class MainClass {public static void main(String args[]) {
    FileInputStream fIn;
    FileOutputStream fOut;
    FileChannel fIChan, fOChan;
    long fSize;
    MappedByteBuffer mBuf;try {
    fIn = new FileInputStream(args[0]);
    fOut = new FileOutputStream(args[1]);fIChan = fIn.getChannel();
    fOChan = fOut.getChannel();fSize = fIChan.size();mBuf = fIChan.map(FileChannel.MapMode.READ_ONLY, 0, fSize);fOChan.write(mBuf); // this copies the filefIChan.close();
    fIn.close();fOChan.close();
    fOut.close();
    } catch (IOException exc) {
    System.out.println(exc);
    System.exit(1);
    } catch (ArrayIndexOutOfBoundsException exc) {
    System.out.println("Usage: Copy from to");
    System.exit(1);
    }
    }
    }
      

  4.   

    如果是把数据库表里的东西给提出到excel表格的话,直接用javascript引擎就行,应该是导入一个jxt.jar