本文整理匯總了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;
}
}
示例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;
}
示例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);
}
示例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);
}
示例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));
}
}