List of usage examples for com.google.common.io Resources readLines
public static List<String> readLines(URL url, Charset charset) throws IOException
From source file:com.github.lukaszkusek.xml.comparator.XMLComparatorBuilder.java
public XMLComparatorBuilder xPathsToOmit(String filePath) throws IOException { this.xPathsToOmit = ImmutableSet.copyOf(Resources.readLines(new URL(filePath), Charsets.UTF_8)); return this; }
From source file:com.tdunning.plume.local.lazy.LazyPlume.java
/** * I guess the convention is that resource files are small enough to be read in memory *///from www .j a va 2 s . c om @Override public PCollection<String> readResourceFile(String name) throws IOException { return fromJava(Resources.readLines(Resources.getResource(name), Charsets.UTF_8)); }
From source file:org.isisaddons.wicket.wizard.webapp.WizardWicketApplication.java
private static String readLines(Class<?> contextClass, final String resourceName) { try {/* w ww. j a v a2 s .c om*/ List<String> readLines = Resources.readLines(Resources.getResource(contextClass, resourceName), Charset.defaultCharset()); final String aboutText = Joiner.on("\n").join(readLines); return aboutText; } catch (IOException e) { return APP_NAME; } }
From source file:org.isisaddons.wicket.svg.webapp.SvgWicketApplication.java
private static String readLines(final Class<?> contextClass, final String resourceName) { try {//from ww w. j a v a 2s . c o m List<String> readLines = Resources.readLines(Resources.getResource(contextClass, resourceName), Charset.defaultCharset()); return Joiner.on("\n").join(readLines); } catch (IOException e) { return APP_NAME; } }
From source file:org.isisaddons.module.servletapi.webapp.ServletApiModuleApplication.java
private static String readLines(final Class<?> contextClass, final String resourceName) { try {/*from w w w . java 2 s . c om*/ List<String> readLines = Resources.readLines(Resources.getResource(contextClass, resourceName), Charset.defaultCharset()); final String aboutText = Joiner.on("\n").join(readLines); return aboutText; } catch (IOException ex) { return APP_NAME; } }
From source file:com.github.fhirschmann.clozegen.lib.multiset.ReadMultisets.java
/** * Parses conditional frequencies from a URL. The subject and the count for a subject * need to be delimited by {@code \t} with the count on the right-hand side. * * <p>Additionally, the remaining words on the left-hand side are split using the * whitespace as delimiter. The {@code key} parameter identifies the condition * by which the rest of the word sequence (with the key itself removed) is identified * by./* ww w .ja va2 s. c o m*/ * * <p>For example, assuming your frequency file contains the following lines: * <pre> * one of 200 * because of 100 * members of 50 * </pre> * Then selecting {@code 0} as key will yield a count of 100 when * looking up "of" given the the key (condition) is "because". * * @param url the URL to the file to parse * @param key the key to identify the word sequence by * @param charset the charset of the file * @return the parsed frequencies * @throws IOException on errors reading from the file * @throws URISyntaxException on errors during URI conversion */ public static MapMultiset<String, String> parseMapMultiset(final URL url, final int key, final Charset charset) throws IOException, URISyntaxException { final MapMultiset<String, String> mms = MapMultiset.create(); final List<String> lines = Resources.readLines(checkNotNull(url), charset); for (String line : lines) { final String[] tokens = line.split("\t"); final String[] ngram = tokens[0].split(" "); StringBuilder sb = new StringBuilder(); for (int i = 0; i < ngram.length; i++) { if (i != key) { sb.append(ngram[i]); } } mms.add(ngram[key], sb.toString(), Integer.parseInt(tokens[1])); } return mms; }
From source file:org.isisaddons.module.excel.webapp.ExcelModuleDemoToDoApplication.java
private static String readLines(final Class<?> contextClass, final String resourceName) { try {/*from w ww . j a v a2 s . c o m*/ List<String> readLines = Resources.readLines(Resources.getResource(contextClass, resourceName), Charset.defaultCharset()); final String aboutText = Joiner.on("\n").join(readLines); return aboutText; } catch (IOException e) { return APP_NAME; } }
From source file:neoapp.webapp.NeoApplication.java
private static String readLines(final Class<?> contextClass, final String resourceName) { try {/*w w w. ja v a2 s.c om*/ List<String> readLines = Resources.readLines(Resources.getResource(contextClass, resourceName), Charset.defaultCharset()); final String aboutText = Joiner.on("\n").join(readLines); return aboutText; } catch (IOException e) { return "This is the neoapp"; } }
From source file:org.activityinfo.server.database.hibernate.HibernateModule.java
public static List<Class> getPersistentClasses() { try {// w ww . ja va 2 s . c o m List<Class> list = Lists.newArrayList(); List<String> lines = Resources.readLines(HibernateModule.class.getResource("/persistent.classes"), Charsets.UTF_8); for (String line : lines) { list.add(Class.forName(line)); } return list; } catch (Exception e) { throw new RuntimeException("Exception loading list of persistent classes", e); } }
From source file:nl.socrates.app.webapp.SocratesApp.java
private static String readLines(final String resourceName) { try {//from w w w . j a v a 2 s.c o m List<String> readLines = Resources.readLines(Resources.getResource(SocratesApp.class, resourceName), Charset.defaultCharset()); final String aboutText = Joiner.on("\n").join(readLines); return aboutText; } catch (IOException e) { return "This is Quick Start"; } }