import java.io.*;
public class test {
 public static void main(String args[]) { 
   File file = new File("letter.txt");
   String path = file.getAbsolutePath();
   System.out.println(path);
   FileInputStream infile = new FileInputStream(path);
   FileOutputStream outfile = new FileOutputStream("dd.txt");
           ……………………????
 }
}

解决方案 »

  1.   

    import java.io.*;
    public class copyfile
     {   public static void main(String args[])
              {byte[]bytes=new byte[4];
               if(args.length<2)
                   {System.err.println("error");
                   return;
                   }
              try{
                  FileInputStream inf=new FileInputStream(args[0]);
                  FileOutputStream  outf=new FileOutputStream(args[1]);
                  int count;
                  while((count=inf.read(bytes))!=-1)
                     {
                       outf.write(bytes,0,count);
                       outf.flush();
                     }
                  outf.close( );
                  inf.close( );
                  }           catch(IOException e)
                   {System.err.println(e);
                    return;
                   }
               }
      }
      

  2.   

    小弟自己找到答案了
    http://expert.csdn.net/Expert/topic/1816/1816445.xml?temp=.9384729希望 zhjjava(狂人一个) 和提供地址的beyond_xiruo(又再次无奈的离开) 
    来领补助!kkkkkk
      

  3.   

    o ,谢谢fangyi1120(fangyi)了,我也一并给分
      

  4.   

    你最好用字符流BufferedReader、PrintWriter,这是JDK1.2后推出的替代JDK1.1中的字节流的!用字节流在JDK1。3后续版本中有些方法不支持!
      

  5.   

    import java.io.*;public class doFile {
    public void copyfile(String str,String str1) throws FileNotFoundException {
    try {
    File file=new File(str);
    InputStream is=null;
    OutputStream os=null;
    byte[] b;
    File f=new File(str1);
    if(!file.isDirectory()) {
      is=new FileInputStream(str);
      b=new byte[is.available()];
      is.read(b);
      os=new FileOutputStream(str1);
      os.write(b);
      is.close();
      os.close();
      return;
    } else if(!f.exists())
      f.mkdirs();
    File[] filename=file.listFiles();
    for(int i=0;i<filename.length;i++) {
        copyfile(filename[i].getAbsolutePath(),str1+"/"+filename[i].getName());
    }
    } catch(IOException ex) {
    filecopycount++;
    System.out.println("filecopycount:"+String.valueOf(filecopycount));
    if(filecopycount<=5)
    copyfile(str,str1);
    System.err.println("err:"+ex.toString());
    }
    }
    }
    使用的时候,例如要将C:\1目录拷到D:\1,则
    doFile df=new doFile();
    df.copyfile("C:\\1","D:\\1");
    当然,拷单个文件也可
    df.copyfile("C:\\1\1.txt","D:\\1\\1.txt");