我有一个包含两个字符串的字符串拆分():一个和两个。我将其添加到链表中。现在我需要得到一个的第一个元素。
String split() {
one = "";
two = "";
int index = tableFields.indexOf("(");
if (index > -1){
one = tableFields.substring(0, index);
two = tableFields.substring(index + 1,
tableFields.length() - 1);
return "`" + one + "`" + " "+ two;
}
else {
return "";
}
}
void readTextFile() {
String line;
while (FileReaderScanner.hasNextLine()) {
fieldlist.add(split()); }
}
试试这个:
String yourString = Split();
int startIndex = yourString.indexOf("`") + 1;
int endIndex = yourString.indexOf("`", startIndex);
String result = yourString.substring(startIndex, endIndex);