java能否拷贝EXCEL文件到其他地方 是否用FileInputStream和FileOutputStream实现 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先读取文件,然后通过poi包里的 HSSFWorkbook的对象名.write(要考到的文件);就可以了. 不管什么类型的文件,都可以用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(); } }} 告诉你一个高效的实现,用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);}}} 如果是把数据库表里的东西给提出到excel表格的话,直接用javascript引擎就行,应该是导入一个jxt.jar 局域网多线程下载的问题! 如何抓取Ajax实现的异步传送的网页数据? java中什么是迭代器? 初学Java,问了有关Package的问题 一直没想通,为什么? 请大牛看看我下面的代码,是一个下载文件的Servlet,前几天好用,今天突然出问题了 ---java 中如何使用枚举变量----- 我的Graphics.drawLine为什么没有颜色? 高分求实现及时消息源码! vector 关于文件的问题 问题,急
HSSFWorkbook的对象名.write(要考到的文件);
就可以了.
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();
}
}
}
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);
}
}
}