List of usage examples for com.google.common.io CharSource readLines
public ImmutableList<String> readLines() throws IOException
From source file:org.trnltk.morphology.lexicon.DictionaryLoader.java
public HashSet<Lexeme> load(CharSource charSource) { try {//from w w w .ja v a 2s . c o m // could have created a line processor, but all file will be // read anyway while creating an in-memory lexeme map final List<String> lines = charSource.readLines(); return this.createLexemesFromLines(lines); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:org.locationtech.geogig.cli.test.functional.CLIContext.java
public List<String> runAndParseCommand(boolean failFast, String... command) throws Exception { runCommand(failFast, command);//w w w .j a va 2s .c o m CharSource reader = CharSource.wrap(stdOut.toString(Charsets.UTF_8.name())); ImmutableList<String> lines = reader.readLines(); return lines; }
From source file:chibill.DeobLoader.loader.Remappers.java
public void setupLoadOnly(String deobfFileName, boolean loadAll) { try {//from w ww . j a va2 s . co m File mapData = new File(deobfFileName); LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData)); CharSource srgSource = zis.asCharSource(Charsets.UTF_8); List<String> srgList = srgSource.readLines(); rawMethodMaps = Maps.newHashMap(); rawFieldMaps = Maps.newHashMap(); Builder<String, String> builder = ImmutableBiMap.<String, String>builder(); Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults(); for (String line : srgList) { String[] parts = Iterables.toArray(splitter.split(line), String.class); String typ = parts[0]; if ("CL".equals(typ)) { parseClass(builder, parts); } else if ("MD".equals(typ) && loadAll) { parseMethod(parts); } else if ("FD".equals(typ) && loadAll) { parseField(parts); } } classNameBiMap = builder.build(); } catch (IOException ioe) { } methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size()); fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size()); }
From source file:chibill.DeobLoader.loader.Remappers.java
public void setup(File mcDir, LaunchClassLoader classLoader, String deobfFileName) { this.classLoader = classLoader; try {/*from w ww.ja v a 2 s .c om*/ InputStream classData = getClass().getResourceAsStream(deobfFileName); LZMAInputSupplier zis = new LZMAInputSupplier(classData); CharSource srgSource = zis.asCharSource(Charsets.UTF_8); List<String> srgList = srgSource.readLines(); rawMethodMaps = Maps.newHashMap(); rawFieldMaps = Maps.newHashMap(); Builder<String, String> builder = ImmutableBiMap.<String, String>builder(); Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults(); for (String line : srgList) { String[] parts = Iterables.toArray(splitter.split(line), String.class); String typ = parts[0]; if ("CL".equals(typ)) { parseClass(builder, parts); } else if ("MD".equals(typ)) { parseMethod(parts); } else if ("FD".equals(typ)) { parseField(parts); } } classNameBiMap = builder.build(); } catch (IOException ioe) { } methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size()); fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size()); }
From source file:net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper.java
public void setupLoadOnly(String deobfFileName, boolean loadAll) { try {//from w w w. j av a 2 s. c o m File mapData = new File(deobfFileName); LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData)); CharSource srgSource = zis.asCharSource(Charsets.UTF_8); List<String> srgList = srgSource.readLines(); rawMethodMaps = Maps.newHashMap(); rawFieldMaps = Maps.newHashMap(); Builder<String, String> builder = ImmutableBiMap.<String, String>builder(); Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults(); for (String line : srgList) { String[] parts = Iterables.toArray(splitter.split(line), String.class); String typ = parts[0]; if ("CL".equals(typ)) { parseClass(builder, parts); } else if ("MD".equals(typ) && loadAll) { parseMethod(parts); } else if ("FD".equals(typ) && loadAll) { parseField(parts); } } classNameBiMap = builder.build(); } catch (IOException ioe) { FMLRelaunchLog.log(Level.ERROR, "An error occurred loading the deobfuscation map data", ioe); } methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size()); fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size()); }
From source file:net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper.java
public void setup(File mcDir, LaunchClassLoader classLoader, String deobfFileName) { this.classLoader = classLoader; try {/*from w ww . j a v a 2 s . co m*/ List<String> srgList; final String gradleStartProp = System.getProperty("net.minecraftforge.gradle.GradleStart.srg.srg-mcp"); if (Strings.isNullOrEmpty(gradleStartProp)) { // get as a resource InputStream classData = getClass().getResourceAsStream(deobfFileName); LZMAInputSupplier zis = new LZMAInputSupplier(classData); CharSource srgSource = zis.asCharSource(Charsets.UTF_8); srgList = srgSource.readLines(); } else { srgList = Files.readLines(new File(gradleStartProp), Charsets.UTF_8); } rawMethodMaps = Maps.newHashMap(); rawFieldMaps = Maps.newHashMap(); Builder<String, String> builder = ImmutableBiMap.<String, String>builder(); Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults(); for (String line : srgList) { String[] parts = Iterables.toArray(splitter.split(line), String.class); String typ = parts[0]; if ("CL".equals(typ)) { parseClass(builder, parts); } else if ("MD".equals(typ)) { parseMethod(parts); } else if ("FD".equals(typ)) { parseField(parts); } } classNameBiMap = builder.build(); } catch (IOException ioe) { FMLRelaunchLog.log(Level.ERROR, ioe, "An error occurred loading the deobfuscation map data"); } methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size()); fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size()); }
From source file:org.infinitest.config.InfinitestConfigurationParser.java
public InfinitestConfiguration parseFileContent(CharSource textConfiguration) throws IOException { List<String> excludedPatterns = new ArrayList<String>(); List<String> includedPatterns = new ArrayList<String>(); List<String> includedGroups = new ArrayList<String>(); List<String> excludedGroups = new ArrayList<String>(); List<String> testngListeners = new ArrayList<String>(); // Be careful the order of the parsers below is important as the lousy // parsers are put at the end ImmutableList<LineParser> orderedLineParsers = ImmutableList.<LineParser>builder() .add(new PatternLineParser(linePattern("include"), includedPatterns)) .add(new PatternLineParser(linePattern("exclude"), excludedPatterns)) .add(new PatternLineParser(linePattern("includeGroups"), includedGroups)) .add(new PatternLineParser(linePattern("excludeGroups"), excludedGroups)) .add(new PatternLineParser(linePattern("testngListeners"), testngListeners)) .add(new PatternLineParser(legacySyntaxLinePattern("groups"), includedGroups)) .add(new PatternLineParser(legacySyntaxLinePattern("excluded-groups"), excludedGroups)) .add(new PatternLineParser(legacySyntaxLinePattern("listeners"), testngListeners)) .add(new CommentLineParser()) // Catch all remaining lines as legacy excluded patterns .add(new PatternLineParser(Pattern.compile("(.*)"), excludedPatterns)).build(); for (String line : textConfiguration.readLines()) { for (LineParser lineParser : orderedLineParsers) { if (lineParser.processLineIfRelevant(line)) { break; }/*from www .ja v a2s .co m*/ } } return InfinitestConfiguration.builder().excludedPatterns(excludedPatterns) .includedPatterns(includedPatterns).excludedGroups(excludedGroups).includedGroups(includedGroups) .testngListeners(testngListeners).build(); }