2017-11-09 11 views

答えて

1

urlからファイルをコピーするには時間がかかり、すでにクラスパス上にApache Commonsがあるので、問題にはConcurrentUtilsクラスを使用するとよいでしょう。 downloadFile()方法はいバイト

public Long downloadFile() throws IOException { 
    File target = new File(fileName); 
    FileUtils.copyURLToFile(new URL(url), target); 
    return target.length(); 
} 
+0

をファイルの長さを返す実装を提供

long lengthInBytes = ConcurrentUtils.constantFuture(downloadFile()).get(); 

、これが働きました。ありがとう! –

関連する問題