2017-11-14 2 views
0

tar.gz 형식의 파일이 있습니다. 나는 그것의 경로를 읽은 다음 내가 만든 임시 디렉토리에 그것을 쓰려고합니다. 디렉토리는 파일로 쓰여집니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까? 나는 scala에서 이것을하고 있지만 자바 클래스를 사용하고있다.자바의 임시 디렉토리를 덮어 쓰는 중

def restore(id: String) = { 
    Future { 
     val sourceDir = getSourceFile(id) 
     val f = { 
     new File(sourceDir) 
     } 
     if (!f.exists()) 
     throw ResourceNotFoundException(s"Failed") 

     val tmpDir = Files.createTempDirectory("restoreMe") 

     val p = Paths.get(s"${tmpDir.toAbsolutePath().toString}/") 
     Files.copy(f.toPath, p, StandardCopyOption.REPLACE_EXISTING); 
    } 
    } 

답변

2

사용이

Path src = f.toPath 
Files.copy(src, p.resolve(src.getFileName()), StandardCopyOption.REPLACE_EXISTING); 
+0

덕분에, 첫 번째 사진에서 직선했다. "src.getName())"을 의미하는 사소한 수정은 내가 생각하는 것입니다. – curiousengineer

관련 문제