标签:style http io ar color os sp for java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
public
static
void
main(String[] args) { /**
根据模板 提取字符串 到List**/ String
string = "ggg
Duplicate entry ‘aaaak‘ for key ‘bbbbk‘gggg" ; String
tpl = "Duplicate
entry ‘%s‘ for key ‘%s‘" ; List<String>
fragments = Splitter.on( "%s" ).splitToList(tpl); List<String>
chips = Lists.newArrayList(); //System.out.println(string.length()); int
idx = 0 ; int
start = 0 ; for ( int
i= 0 ;i<=fragments.size();i++){ if (i!=fragments.size()){ String
fragment = fragments.get(i); idx
= string.indexOf(fragment,start); if (idx!=start){
//头处理 String
chip = string.substring(start, idx); chips.add(chip); //System.out.println(string.substring(start,
idx)); //System.out.println(idx+fragment.length()); } start
= idx+fragment.length(); } else { //尾处理 chips.add(string.substring(start)); } } System.out.println(chips); } |
标签:style http io ar color os sp for java
原文地址:http://blog.csdn.net/u014311051/article/details/41870899