Wrathchild
Technical User
I'm using the following code to detect the presence of a backslash:
String slash = path.substring(0, path.indexOf("/"));
int x = slash.length();
And then I want to use the result in an If statement...If(x>0)...but if 'path' doesn't contain a backslash, it errors saying the string is out of range, which I believe is because if the character doesn't exist it returns -1. Is there a way I can use this method when characters don't exist?
thanks!
String slash = path.substring(0, path.indexOf("/"));
int x = slash.length();
And then I want to use the result in an If statement...If(x>0)...but if 'path' doesn't contain a backslash, it errors saying the string is out of range, which I believe is because if the character doesn't exist it returns -1. Is there a way I can use this method when characters don't exist?
thanks!