/** * Get the contents of <code>file</code> as a <code>String</code> using the platform's default character encoding. */ public static final String toString(File file) { return toString(file, null); }
/** * Get the contents of <code>location</code> as a <code>String</code> using the platform's default character encoding. */ public static final String toString(String location) { return toString(location, null); }
/** * Get the contents of <code>file</code> as a <code>String</code> using the specified character encoding. */ public static final String toString(File file, String encoding) { return toString(getCanonicalPath(file), encoding); }
protected String getFilteredContent(String location, Properties properties, String encoding) { PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", ":", true); String originalContent = LocationUtils.toString(location, encoding); String filteredContent = helper.replacePlaceholders(originalContent, properties); return filteredContent; }
/** * Return a new <code>Properties</code> object loaded from <code>location</code> where the properties are stored in Rice XML style syntax * * @deprecated use loadRiceProps() instead */ @Deprecated public static final Properties loadRiceProperties(String location) { logger.info("Loading Rice properties [{}] encoding={}", location, DEFAULT_XML_ENCODING); String contents = LocationUtils.toString(location, DEFAULT_XML_ENCODING); String config = StringUtils.substringBetween(contents, "<config>", "</config>"); String[] tokens = StringUtils.substringsBetween(config, "<param", "<param"); Properties properties = new Properties(); for (String token : tokens) { String key = StringUtils.substringBetween(token, "name=\"", "\">"); validateRiceProperties(token, key); String value = StringUtils.substringBetween(token + "</param>", "\">", "</param>"); properties.setProperty(key, value); } return properties; }
public static void copyFiles(SecureChannel channel, List<Deployable> deployables, Properties filterProperties) { if (CollectionUtils.isEmpty(deployables)) { return; } for (Deployable deployable : deployables) { RemoteFile destination = new RemoteFile.Builder(deployable.getRemote()).build(); String location = deployable.getLocal(); logger.info(" creating -> [{}]", destination.getAbsolutePath()); if (deployable.isFilter()) { long start = System.currentTimeMillis(); String originalContent = LocationUtils.toString(location); String resolvedContent = HELPER.replacePlaceholders(originalContent, filterProperties); channel.copyStringToFile(resolvedContent, destination); String elapsed = FormatUtils.getTime(System.currentTimeMillis() - start); Object[] args = { filterProperties.size(), location, destination.getAbsolutePath(), elapsed }; logger.debug("Used {} properties to filter [{}] -> [{}] - {}", args); } else { long start = System.currentTimeMillis(); channel.copyLocationToFile(location, destination); logCopy(location, destination.getAbsolutePath(), System.currentTimeMillis() - start); } if (deployable.getPermissions().isPresent()) { String path = deployable.getRemote(); String perms = deployable.getPermissions().get(); String command = CMDS.chmod(perms, path); executePathCommand(channel, command, path); } } }
content = LocationUtils.toString(file, encoding); contains = StringUtils.contains(content, token); if (contains) {