當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。