Ran*_*del 7 android string-utils
我在Android代码中使用StringUtils类.但是生成异常,即找不到类.但是我已经在那个类中使用了jar文件.请帮我!
我的问题通过以下代码解决,我们不需要使用 StringUtils jar 来添加我们的项目。
我创建了自己的类,即“RanjitString”,替换为 StringUtils。
public class RanjitString {
public static String substringBetween(String str, String open, String close) {
if (str == null || open == null || close == null) {
return null;
}
int start = str.indexOf(open);
if (start != -1) {
int end = str.indexOf(close, start + open.length());
if (end != -1) {
return str.substring(start + open.length(), end);
}
}
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
并直接访问静态方法substringBetween:
String myxml="This is my xml with different tags";
String successResult = RanjitString.substringBetween(myxml,
"<tag>", "</tag>");
Run Code Online (Sandbox Code Playgroud)
这段代码对我有用......
| 归档时间: |
|
| 查看次数: |
15312 次 |
| 最近记录: |