1.copy 
2.delete/**  
     *  复制单个文件  
     *  @param  String oldPath   原文件路径  如:c:/a.txt  
     *  @param  String newPath   复制后路径  如:f:/a.txt  
     */  
public static void  copyFile(String  oldPath,  String  newPath)  
{  
try  
{  
int  bytesum  =  0;  
int  byteread  =  0;  
File  oldfile  =  new  File(oldPath);  
if  (oldfile.exists())  
{  //文件存在时  
InputStream  inStream  =  new  FileInputStream(oldPath);  //读入原文件  
FileOutputStream  fs  =  new  FileOutputStream(newPath);  
byte[]  buffer  =  new  byte[1444];  
int  length;  
while  (  (byteread  =  inStream.read(buffer))  !=  -1)  
{  
bytesum  +=  byteread;  //字节数  文件大小  
//System.out.println(bytesum);  
fs.write(buffer,  0,  byteread);  
}  
inStream.close();  
}  
}  
catch  (Exception  e)  
{  
//System.out.println("复制单个文件操作出错");  
e.printStackTrace();  
}  

}  

/**  
     *  删除单个文件  
     *  @param  String Path       文件路径  
     *  @param  String filename   文件名  
     */  
public static void  delFile(String  Path,  String  filename)  

               try{
                String path=application.getRealPath(Path);
                File fobj=new File(path,filename);
                boolean bo_Return=fobj.delete();
               }
                catch  (Exception  e)  
{  
//System.out.println("删除单个文件操作出错");  
e.printStackTrace();  
}      
          }

解决方案 »

  1.   

    楼上的楼上方法麻烦了吧
    java.io.File createNewFile() delete()就可以了
      

  2.   

    可以用File类的renameTo()方法。
    File srcFile = new File("c:/aaa.txt");//存在的源文件
    File dtnFile = new File("d:/bbb.txt"); //制定目标文件路径以及文件名
    srcFile.renameTo(dtnFile);
      

  3.   

    renameTo()方法可以吗,马上试一下。geting