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() 方法无法做到这一点。代码有什么问题吗?

4

1 回答 1

0

使用FileUtils

FileUtils.moveFile(oldName, newName);
于 2012-07-16T12:30:08.600 回答