/** * Localizes the specified {@link LocalizeResource} in the specified {@link File targetDir} with the specified * file name and returns the {@link File} pointing to the localized file. * * @param fileName the name to localize the file with * @param resource the {@link LocalizeResource} to localize * @param targetDir the directory to localize the resource in * @return the {@link File} pointing to the localized file. */ public static File localizeResource(String fileName, LocalizeResource resource, File targetDir) throws IOException { File localizedResource = new File(targetDir, fileName); File input = getFileToLocalize(resource, targetDir); if (resource.isArchive()) { LOG.debug("Decompress file {} to {}", input, localizedResource); unpack(input, localizedResource); } else { try { LOG.debug("Hard link file from {} to {}", input, localizedResource); java.nio.file.Files.createLink(Paths.get(localizedResource.toURI()), Paths.get(input.toURI())); } catch (Exception e) { LOG.debug("Copy file from {} to {}", input, localizedResource); Files.copy(input, localizedResource); } } return localizedResource; }
/** * Localizes the specified {@link LocalizeResource} in the specified {@link File targetDir} with the specified * file name and returns the {@link File} pointing to the localized file. * * @param fileName the name to localize the file with * @param resource the {@link LocalizeResource} to localize * @param targetDir the directory to localize the resource in * @return the {@link File} pointing to the localized file. */ public static File localizeResource(String fileName, LocalizeResource resource, File targetDir) throws IOException { File localizedResource = new File(targetDir, fileName); File input = getFileToLocalize(resource, targetDir); if (resource.isArchive()) { LOG.debug("Decompress file {} to {}", input, localizedResource); unpack(input, localizedResource); } else { try { LOG.debug("Hard link file from {} to {}", input, localizedResource); java.nio.file.Files.createLink(Paths.get(localizedResource.toURI()), Paths.get(input.toURI())); } catch (Exception e) { LOG.debug("Copy file from {} to {}", input, localizedResource); Files.copy(input, localizedResource); } } return localizedResource; }