String str = "aaaaaaaa埲aaaaa$33";
// int i = str.lastIndexOf("$");
// 不知道你的需要是?
int i = str.lastIndexOf("$");
// 如果必要的话,检查一下i的值
String result = str.substring(i + 1, str.length());
System.out.println(result);
使用StringTokenizer类分解字符串,他的默认的token是空格!
import java.util.*;
public class test {
public test(){}
public static void main(String[] args) {
test test1 = new test();
String preStr = null;
StringTokenizer st = new StringTokenizer("aaaaaaaa以aaaaa$33","$");
while(st.hasMoreElements()){
preStr = st.nextToken();
}
System.out.println(preStr);
}
}