本帖最后由 杨杨 于 2013-3-3 10:18 编辑
- package cn.test;
- import java.io.BufferedInputStream;
- import java.io.BufferedOutputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.InputStream;
- import java.io.OutputStream;
- public class Test {
- public static void main(String[] args) {
- String src="F:/workspace/FreeCMS/WebContent/templet/freecms/栏目信息列表.html";
- File src1=new File(src) ;
- String dist="F:/workspace/FreeCMS/WebContent/templet/freecms/1栏目信息列表.html";
- File dist1= new File(dist);
- copy(src1,dist1);
- }
- public static void copy(File src, File dst) {
- try {
- int BUFFER_SIZE=16 * 1024 ;
- InputStream in = null;
- OutputStream out = null;
- try {
- in = new BufferedInputStream(new FileInputStream(src),
- BUFFER_SIZE);
- out = new BufferedOutputStream(new FileOutputStream(dst),
- BUFFER_SIZE);
- byte[] buffer = new byte[BUFFER_SIZE];
- while (in.read(buffer) > 0) {
- out.write(buffer);
- }
- } finally {
- if (null != in) {
- in.close();
- }
- if (null != out) {
- out.close();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
复制代码 在复制两个文件的时候老是出现
乱码
|
|