2012-06-27 35 views
0
String oldName = D:\careers.bstalents.com\build\web\uploads\Resume\old.doc; 
String newName = D:\careers.bstalents.com\build\web\uploads\Resume\new.doc; 

      File newFile = new File(newName); 
      File oldFile = new File(oldName); 
      boolean rename = oldFile.renameTo(newFile); 
      if (rename) { 

        outs.write(formFile.getFileData()); 
        outs.close();*/ 
        FileOutputStream fileOutStream = new FileOutputStream(newFile); 
        fileOutStream.write(resume.getFileData()); 
        fileOutStream.flush(); 
        fileOutStream.close(); 
       } 

我发布了上面的代码,请分享您的意见。这里renameTo()方法无法做到这一点。是否在代码中存在任何问题?如何在java中使用新名称重命名简历(.doc)

+0

将ü把你做了什么错误,因为它的工作对我很好.. –

+0

当我打印重命名控制台它返回假,如果重命名= false,那么它不会去在if block中,所以我不能在新文件中写入内容。 –

+1

也许你的old.doc仍然被其他程序打开? –

回答

相关问题