@Test public void copy_to_file() throws Exception { FileLocator locator = new FileLocator(); File fileToCopy = new File(getClass().getResource("/com/sonar/orchestrator/locator/FileLocatorTest/foo.txt").toURI()); File toFile = temp.newFile(); File copy = locator.copyToFile(FileLocation.of(fileToCopy), toFile); assertThat(copy).isNotNull(); assertThat(copy).isSameAs(toFile); assertThat(copy.length()).isGreaterThan(0L); }
@Override public File copyToFile(FileLocation fileLocation, File toFile) { File file = locate(fileLocation); if (file != null && file.exists()) { try { FileUtils.copyFile(file, toFile); } catch (IOException e) { throw new IllegalStateException("Fail to copy to file: " + toFile, e); } } return toFile; }
FileLocator implements Locator<FileLocation> { @Override public File copyToFile(FileLocation fileLocation, File toFile) { File file = locate(fileLocation); if (file != null && file.exists()) { try { FileUtils.copyFile(file, toFile); } catch (IOException e) { throw new IllegalStateException("Fail to copy to file: " + toFile, e); } } return toFile; } }
FileLocator implements Locator<FileLocation> { @Override public File copyToFile(FileLocation fileLocation, File toFile) { File file = locate(fileLocation); if (file != null && file.exists()) { try { FileUtils.copyFile(file, toFile); } catch (IOException e) { throw new IllegalStateException("Fail to copy to file: " + toFile, e); } } return toFile; }  }
FileLocator implements Locator<FileLocation> { @Override public File copyToFile(FileLocation fileLocation, File toFile) { File file = locate(fileLocation); if (file != null && file.exists()) { try { FileUtils.copyFile(file, toFile); } catch (IOException e) { throw new IllegalStateException("Fail to copy to file: " + toFile, e); } } return toFile; }  @Override File locate(FileLocation location); @Override File copyToDirectory(FileLocation fileLocation, File toDir); @Override File copyToFile(FileLocation fileLocation, File toFile); @Override InputStream openInputStream(FileLocation location); }
FileLocator implements Locator<FileLocation> { @Override public File copyToFile(FileLocation fileLocation, File toFile) { File file = locate(fileLocation); if (file != null && file.exists()) { try { FileUtils.copyFile(file, toFile); } catch (IOException e) { throw new IllegalStateException("Fail to copy to file: " + toFile, e); } } return toFile; }  @Override File locate(FileLocation location); @Override File copyToDirectory(FileLocation fileLocation, File toDir); @Override File copyToFile(FileLocation fileLocation, File toFile); @Override InputStream openInputStream(FileLocation location);  }