Trying to parse filename from selectInput(), can't split on "\"
in
Programming Questions
•
1 year ago
I'm trying to extract the filename from a string loadPath (got from loadPath = selectInput() ). I need my user to load a file and then I background load other files that have the same filename but with a different extension. I therefore want to extract the filename and then issue a command to load the version with the different extension.
For example, if my user loaded image.jpg I'd like to also load image.png. I need to extract filename "image", append ".png" and load that.
I'm using
- String[] qpath = splitTokens(loadPath,"\");
but Processing doesn't like "\" at all and won't let me split on that character. I wanted to split the path string into an array of pieces delimited by "\" and then I'd have the last array element which would be the filename.
Any suggestions as to a better way to get the filename, or how can I split a string on "\"?
Thanks in advance
1