renameTo() 사용에 이상한 문제가 있습니다. /mnt/desttest
으로 이름을 바꿀 수없는 이유는 모르지만 /home/kit.ho/desttest
으로 바꿔도됩니다. 그러나 이미 모든 쓰기 권한을/mnt /에 부여합니다. 특별한 이유가없는 동안 반환 값은 false입니다. 이유는 누가 알겠는가?파일을 다른 파일 시스템으로 이름을 바꾸는 방법은 무엇입니까?
import java.io.File;
public class renameFile {
public static void main(String[] args) {
File sourceFile = new File("/home/kit.ho/test");
File targetFile1 = new File("/mnt/desttest");
System.out.println("source file is exist? " + sourceFile.exists() + ", source file => " + sourceFile);
System.out.println(targetFile1 + " is exist? " + targetFile1.exists());
System.out.println("rename to " + targetFile1 + " => " + sourceFile.renameTo(targetFile1));
System.out.println("source file is exist? " + sourceFile.exists() + ", source file => " + sourceFile);
}
}
편집 : 마지막으로, 어떤 대답을 기반으로, 파일 시스템에 걸쳐에서 작동하지 않는 기능을 이름 바꾸기, "뮤직 비디오"와 같은 외부 명령을 호출하지 않음으로써이 문제에 어떤 해결 방법이?
'/ mnt'는 별도의 파티션입니까? –
'mv /home/kit.ho/test/mnt/ desttest' 문제없이 할 수 있습니까? – Martin
@ 기계 : yes/mnt는 별도의 파티션에 있습니다. –