importjava.io.*;classCopyFile{publicstaticvoidmain(Stringargs[])throwsIOException{inti;FileInputStreamfin;FileOutputStreamfout;try{try{fin=newFileInputStream(args[0]);//创...
import java.io.*; class CopyFile{ public static void main(String args[])throws IOException{ int i; FileInputStream fin; FileOutputStream fout; try{ try{ fin=new FileInputStream(args[0]); //创建输入文件的对象 } catch(FileNotFoundException e){ System.out.println("输入文件未找到!"); return; } try{ fout=new FileOutputStream(args[1]); //创建输出文件对象 } catch(FileNotFoundException e){ System.out.println("打开输出文件有错误!"); return; } } catch(ArrayIndexOutOfBoundsException e){ System.out.println("格式错误!"); System.out.println("使用格式为: CopyFile 源文件名 目标文件名!"); return; } try{ while((i=fin.read())!=-1) fout.write(i); } catch(IOException e){ System.out.println("文件有错误!"); } fin.close(); // 关闭此输入流并释放与此流关联的所有系统资源。 fout.close(); } } 问题: fin=new FileInputStream(args[0]); 中 args[0]怎么理解 同样,还有下面的args[1]) 如果args[0] args[1]代表参数的话,那么为什么改成别的标志符就不行了? 还有的是 这样写之后,为什么一定要到命令提示符下运行?
展开