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


Java Splitter.splitToList方法代码示例

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


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

示例1: getModSlug0

import com.google.common.base.Splitter; //导入方法依赖的package包/类
@Nullable
private String getModSlug0(int id)
{
    try
    {
        log.debug("Getting mod slug from server...");
        URI uri = getURI(CURSEFORGE_URL, String.format(PROJECT_PATH, id), null);
        HttpGet request = new HttpGet(uri.toURL().toString());
        HttpContext context = new BasicHttpContext();
        HttpResponse response = http.execute(request, context);
        EntityUtils.consume(response.getEntity());
        HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(HttpCoreContext.HTTP_REQUEST);
        HttpHost currentHost = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
        String currentUrl = (currentReq.getURI().isAbsolute()) ? currentReq.getURI().toString() : (currentHost.toURI() + currentReq.getURI());
        Splitter splitter = Splitter.on('/').omitEmptyStrings();
        List<String> pathParts = splitter.splitToList(currentUrl);
        return pathParts.get(pathParts.size() - 1);
    }
    catch (Exception e)
    {
        log.error("Failed to perform request from CurseForge site.", e);
        return null;
    }
}
 
开发者ID:PaleoCrafter,项目名称:CurseSync,代码行数:25,代码来源:CurseAPI.java

示例2: load

import com.google.common.base.Splitter; //导入方法依赖的package包/类
public boolean load(InputStream in) throws IOException {

        Splitter splitter = Splitter.on(',').trimResults();
        try (BufferedReader br = new BufferedReader(new InputStreamReader(in,
                "UTF-8"))) {
            String firstline = br.readLine();
            List<String> lablist = splitter.splitToList(firstline);
            matrix = ArrayTable.create(lablist.subList(1, lablist.size()),
                    lablist.subList(1, lablist.size())); // 为了制表方便,第一个label是空白,所以要抹掉它
            // //之后就描述了矩阵
            String line = null;
            while ((line = br.readLine()) != null) {
                List<String> paramArray = splitter.splitToList(line);
                String row_lable = paramArray.get(0);
                Map<String, Integer> row = matrix.row(row_lable);
                for (int i = 1; i < paramArray.size(); i++) {
                    row.put(lablist.get(i), Integer.parseInt(paramArray.get(i)));
                }
            }
        }

        tongji();
        return true;
    }
 
开发者ID:mayabot,项目名称:mynlp,代码行数:25,代码来源:TransformMatrix.java

示例3: loadFromRealData

import com.google.common.base.Splitter; //导入方法依赖的package包/类
@Override
public void loadFromRealData() throws Exception {
    TreeMap<String, V> map = new TreeMap<>();
    long t1 = System.currentTimeMillis();

    MynlpResource resource = environment.getMynlpResourceFactory().load(dicFilePath());

    Splitter splitter = Splitter.on(Pattern.compile("\\s"));
    try (CharSourceLineReader reader = resource.openLineReader()) {
        while (reader.hasNext()) {
            String line = reader.next();
            List<String> params = splitter.splitToList(line);
            if (!params.isEmpty()) {
                List<String> attrs = params.subList(1, params.size());
                V attribute = parseLine(attrs);
                map.put(params.get(0), attribute);
            }
        }
    }

    filtermap(map);

    DoubleArrayTrieBuilder<V> builder = new DoubleArrayTrieBuilder<>();
    this.trie = builder.build(map);
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:26,代码来源:CommonDictionary.java

示例4: DictionaryAidedDepluralizer

import com.google.common.base.Splitter; //导入方法依赖的package包/类
DictionaryAidedDepluralizer(String[] exceptions) {
  Map<String, String> map = Maps.newHashMapWithExpectedSize(exceptions.length);
  Splitter splitter = Splitter.on(':');
  for (String s : exceptions) {
    List<String> parts = splitter.splitToList(s.toLowerCase());
    if (parts.size() == 1) {
      // simple no-depluratization exception
      map.put(parts.get(0), parts.get(0));
    } else if (parts.size() == 2) {
      // singular, then plural, so mapping plural->singular
      map.put(parts.get(1), parts.get(0));
    }
  }
  this.dictionary = ImmutableMap.copyOf(map);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:Depluralizer.java

示例5: readCsv

import com.google.common.base.Splitter; //导入方法依赖的package包/类
private void readCsv(File file, Map<String, String> map) throws IOException
{
    GradleStartCommon.LOGGER.log(Level.DEBUG, "Reading CSV file: {}", file);
    Splitter split = Splitter.on(',').trimResults().limit(3);
    for (String line : Files.readLines(file, Charsets.UTF_8))
    {
        if (line.startsWith("searge")) // header line
            continue;

        List<String> splits = split.splitToList(line);
        map.put(splits.get(0), splits.get(1));
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:14,代码来源:GradleForgeHacks.java


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