当前位置: 首页>>代码示例>>Java>>正文


Java CharSource.openStream方法代码示例

本文整理汇总了Java中com.google.common.io.CharSource.openStream方法的典型用法代码示例。如果您正苦于以下问题:Java CharSource.openStream方法的具体用法?Java CharSource.openStream怎么用?Java CharSource.openStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.io.CharSource的用法示例。


在下文中一共展示了CharSource.openStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: provideCssRenamingMap

import com.google.common.io.CharSource; //导入方法依赖的package包/类
/** Reads the CSS rename map  */
@Provides
@Singleton
public SoyCssRenamingMap provideCssRenamingMap()
throws IOException {
  ImmutableMap.Builder<String, String> cssMapBuilder = ImmutableMap.builder();

  URL crUrl = getClass().getResource(CSS_RENAMING_MAP_RESOURCE_PATH);
  if (crUrl != null) {
    CharSource cssRenamingMapJson = Resources.asCharSource(
        crUrl, Charsets.UTF_8);
    JsonElement json;
    try (Reader jsonIn = cssRenamingMapJson.openStream()) {
      json = new JsonParser().parse(jsonIn);
    }
    for (Map.Entry<String, JsonElement> e
         : json.getAsJsonObject().entrySet()) {
      cssMapBuilder.put(e.getKey(), e.getValue().getAsString());
    }
  }
  return new SoyCssRenamingMapImpl(cssMapBuilder.build());
}
 
开发者ID:mikesamuel,项目名称:closure-maven-plugin,代码行数:23,代码来源:ClosureModule.java

示例2: parseTree

import com.google.common.io.CharSource; //导入方法依赖的package包/类
static Tree parseTree(CharSource input)
        throws IOException
{
    try (Reader reader = input.openStream()) {
        ThriftLexer lexer = new ThriftLexer(new ANTLRReaderStream(reader));
        ThriftParser parser = new ThriftParser(new CommonTokenStream(lexer));
        try {
            Tree tree = (Tree) parser.document().getTree();
            if (parser.getNumberOfSyntaxErrors() > 0) {
                throw new IllegalArgumentException("syntax error");
            }
            return tree;
        }
        catch (RecognitionException e) {
            throw new IllegalArgumentException(e);
        }
    }
}
 
开发者ID:l3ug1m,项目名称:thrift-java-compiler,代码行数:19,代码来源:ThriftIdlParser.java

示例3: CharSourceLineReader

import com.google.common.io.CharSource; //导入方法依赖的package包/类
public CharSourceLineReader(CharSource charSource) {
    try {
        reader = charSource.openStream();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    lineReader = new LineReader(reader);
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:9,代码来源:CharSourceLineReader.java

示例4: load

import com.google.common.io.CharSource; //导入方法依赖的package包/类
private static Configuration load(int nextIndex, List<URL> configs)
    throws ConfigurationException, IOException {
  CharSource input = CharSource.concat(Iterables.transform(configs, URL_TO_SOURCE));
  try(Reader reader = input.openStream()) {
    return CharStreams.readLines(reader, new ConfigurationParser(nextIndex));
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:8,代码来源:Configuration.java

示例5: givenValidInput_whenGetNextToken_thenProducesFirstToken

import com.google.common.io.CharSource; //导入方法依赖的package包/类
@Test
public void givenValidInput_whenGetNextToken_thenProducesFirstToken() throws IOException {
    CharSource source = wrap("user-agent: example-bot\n");
    RobotsParserImpl parser =new RobotsParserImpl(source.openStream());
    Token token = parser.getNextToken();
    assertThat(token.image, equalTo("user-agent"));
}
 
开发者ID:BrandwatchLtd,项目名称:robots,代码行数:8,代码来源:RobotsParserImplTest.java

示例6: givenValidInput_whenGetFirstToken_thenProducesFirstToken

import com.google.common.io.CharSource; //导入方法依赖的package包/类
@Test
public void givenValidInput_whenGetFirstToken_thenProducesFirstToken() throws IOException {
    CharSource source = wrap("user-agent: example-bot\n");
    RobotsParserImpl parser =new RobotsParserImpl(source.openStream());
    Token token = parser.getToken(1);
    assertThat(token.image, equalTo("user-agent"));
}
 
开发者ID:BrandwatchLtd,项目名称:robots,代码行数:8,代码来源:RobotsParserImplTest.java

示例7: givenLargeToken_whenParse_thenResultEqualsExpected

import com.google.common.io.CharSource; //导入方法依赖的package包/类
@Test
public void givenLargeToken_whenParse_thenResultEqualsExpected() throws IOException, ParseException {
    String useragent = repeat("a", 100000);
    CharSource source = wrap("User-agent: " + useragent + "\n");
    RobotsParserImpl robotsParser = new RobotsParserImpl(source.openStream());
    robotsParser.parse(handler);
    handler.userAgent(useragent);
}
 
开发者ID:BrandwatchLtd,项目名称:robots,代码行数:9,代码来源:RobotsParserImplTest.java

示例8: givenDirectiveStartingWithTab_whenParse_producesOtherDirectiveMatchingInput

import com.google.common.io.CharSource; //导入方法依赖的package包/类
@Test
public void givenDirectiveStartingWithTab_whenParse_producesOtherDirectiveMatchingInput() throws IOException, ParseException {
    CharSource source = wrap("\tfoo: bar");
    RobotsParserImpl parser = new RobotsParserImpl(source.openStream());
    parser.parse(handler);
    verify(handler).otherDirective("\tfoo", "bar");
}
 
开发者ID:BrandwatchLtd,项目名称:robots,代码行数:8,代码来源:RobotsParserImplTest.java

示例9: givenDirectiveStartingWithLineFeed_whenParse_producesOtherDirectiveMatchingInput

import com.google.common.io.CharSource; //导入方法依赖的package包/类
@Test
public void givenDirectiveStartingWithLineFeed_whenParse_producesOtherDirectiveMatchingInput() throws IOException, ParseException {
    CharSource source = wrap("\ffoo: bar");
    RobotsParserImpl parser = new RobotsParserImpl(source.openStream());
    parser.parse(handler);
    verify(handler).otherDirective("\ffoo", "bar");
}
 
开发者ID:BrandwatchLtd,项目名称:robots,代码行数:8,代码来源:RobotsParserImplTest.java

示例10: givenLowerCaseSiteMapDirective_whenParse_producesSiteMap

import com.google.common.io.CharSource; //导入方法依赖的package包/类
@Test
public void givenLowerCaseSiteMapDirective_whenParse_producesSiteMap() throws IOException, ParseException {
    CharSource source = wrap("sitemap: sitemap.xml");
    RobotsParserImpl parser = new RobotsParserImpl(source.openStream());
    parser.parse(handler);
    verify(handler).siteMap("sitemap.xml");
}
 
开发者ID:BrandwatchLtd,项目名称:robots,代码行数:8,代码来源:RobotsParserImplTest.java

示例11: givenUpdateCaseSiteMapDirective_whenParse_producesSiteMap

import com.google.common.io.CharSource; //导入方法依赖的package包/类
@Test
public void givenUpdateCaseSiteMapDirective_whenParse_producesSiteMap() throws IOException, ParseException {
    CharSource source = wrap("SITEMAP: sitemap.xml");
    RobotsParserImpl parser = new RobotsParserImpl(source.openStream());
    parser.parse(handler);
    verify(handler).siteMap("sitemap.xml");
}
 
开发者ID:BrandwatchLtd,项目名称:robots,代码行数:8,代码来源:RobotsParserImplTest.java

示例12: givenUpperCaseAllowDirective_whenParse_producesAllow

import com.google.common.io.CharSource; //导入方法依赖的package包/类
@Test
public void givenUpperCaseAllowDirective_whenParse_producesAllow() throws IOException, ParseException {
    CharSource source = wrap("user-agent: example-bot\nALLOW: *");
    RobotsParserImpl parser = new RobotsParserImpl(source.openStream());
    parser.parse(handler);
    verify(handler).allow("*");
}
 
开发者ID:BrandwatchLtd,项目名称:robots,代码行数:8,代码来源:RobotsParserImplTest.java

示例13: givenLowerCaseAllowDirective_whenParse_producesAllow

import com.google.common.io.CharSource; //导入方法依赖的package包/类
@Test
public void givenLowerCaseAllowDirective_whenParse_producesAllow() throws IOException, ParseException {
    CharSource source = wrap("user-agent: example-bot\nallow: *");
    RobotsParserImpl parser = new RobotsParserImpl(source.openStream());
    parser.parse(handler);
    verify(handler).allow("*");
}
 
开发者ID:BrandwatchLtd,项目名称:robots,代码行数:8,代码来源:RobotsParserImplTest.java

示例14: givenUpperCaseDisallowDirective_whenParse_producesDisallow

import com.google.common.io.CharSource; //导入方法依赖的package包/类
@Test
public void givenUpperCaseDisallowDirective_whenParse_producesDisallow() throws IOException, ParseException {
    CharSource source = wrap("user-agent: example-bot\ndisallow: *");
    RobotsParserImpl parser = new RobotsParserImpl(source.openStream());
    parser.parse(handler);
    verify(handler).disallow("*");
}
 
开发者ID:BrandwatchLtd,项目名称:robots,代码行数:8,代码来源:RobotsParserImplTest.java

示例15: givenLowerCaseDisallowDirective_whenParse_producesDisallow

import com.google.common.io.CharSource; //导入方法依赖的package包/类
@Test
public void givenLowerCaseDisallowDirective_whenParse_producesDisallow() throws IOException, ParseException {
    CharSource source = wrap("user-agent: example-bot\nDISALLOW: *");
    RobotsParserImpl parser = new RobotsParserImpl(source.openStream());
    parser.parse(handler);
    verify(handler).disallow("*");
}
 
开发者ID:BrandwatchLtd,项目名称:robots,代码行数:8,代码来源:RobotsParserImplTest.java


注:本文中的com.google.common.io.CharSource.openStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。