map.put("RowID", String.valueOf(RowID));
map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
解析后我获取数据
13/2012 | Section 10(15), item (h) of sub-clause (iv) of the Income-tax Act, 1961 - Exemptions - Interest on bonds/debentures - Notified bonds/debentures of Public Sector Companies - Corrigendum to notification no.7/2012, dated 14-2-2012
我希望在|
之后分开并打印类似
13/2012 Section
10(15), item (h) of sub-clause (iv) of the Income-tax Act, 1961 - Exemptions - Interest on bonds/debentures - Notified bonds/debentures of Public Sector Companies - Corrigendum to notification no.7/2012, dated 14-2-2012
我该怎么做?
答案 0 :(得分:2)
使用String.replace()。
例如:
String s = "hello | world";
System.out.println(s.replace("|", "\n"));
打印出来:
你好 世界答案 1 :(得分:1)
您可以使用String#replace
方法:
String finalString = oldString.replace("|", "\n");
或使用String#split
:
String[] splitted = oldString.split(Pattern.quote("|"));
答案 2 :(得分:1)
独立于平台(当你在使用android时并不严格需要)
System.out.println(yourString.replaceAll("\\|", System.getProperty("line.separator"));
这将取代所有|以及你的字符串有多个|
的情况