I wrote a function to find a space (in full-width) in a String
. But indexOf
cant find it and returns -1
. This is my function:
public static String getflagCheck(String content) {
List<String> supplierNames = Arrays.asList("//");
String remark = "x";
boolean flagValid = false;
for (int i = 0; i < supplierNames.size(); i++) {
int index = content.indexOf(supplierNames.get(i));
int indexTestPoint = content.indexOf(" ");
System.out.println(index);
System.out.print(indexTestPoint + "\n\n");
if(index > -1) {
flagValid = true;
if(indexTestPoint < index) {
flagValid = false;
}
break;
}
}
if(flagValid) {
remark = "x";
} else {
remark = "needcheck";
}
return remark;
}
Your "space" at
int indexTestPoint = content.indexOf(" ");
Isn't a space character but is a tab character. Replace it with a space.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.