2012-06-27 6 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() 메소드가 수행 할 수 없습니다. 코드에 문제가 있습니까?자바에서 새 이름으로 이력서 (.doc) 이름을 바꾸는 방법

+0

것이다 u는 당신이지고 어떤 오류 넣어 때문에 나에 대한 잘 작동 .. –

+0

내가 이름 변경 후가 거짓 가지 않을 것이다 = 경우는 false를 반환 콘솔에서 이름 바꾸기를 인쇄 할 때 in 블록 그래서 새 파일에있는 내용을 쓸 수 없습니다. –

+1

old.doc이 다른 프로그램에 의해 열렸을 수 있습니까? –

답변