skymysky777
发贴: 31
积分: 0
|
于 2005-06-15 10:37
下面实现的是两个文件复制,我是初学者,这段程序编不过去.还请高手指点. import java.io.*; public class examFile1 { public static void main(String arg[]) { FileInputStream ins; FileInputStream outs; File fileObject2 = new File("d:\\zzz","fstFile.txt"); try { fileObject2.createNewFile(); ins = new FileInputStream("d:\\zzz\\123.txt"); outs = new FileInputStream("d:\\zzz\\fstFile.txt"); copyContent(ins,outs); }catch(FileNotFoundException e) { } catch(IOException e){ } } static void copyContent(FileInputStream inobj,FileOutputStream outobj){ int copyLen; byte[] copyBuf = new byte[1024]; try{ while((copyLen = inobj.read(copyBuf,0,1024))!=-1){ String copyStr= new String(copyBuf); System.out.println(copyStr); outObj.write(copyBuf,0,copyLen); } } catch(IOException e){ System.out.println("asf"+e); } } }
|