• Post Reply Bookmark Topic Watch Topic
  • New Topic

Searching for Unix Slash

 
Mike London
Ranch Hand
Posts: 1290
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a JSP page, I'm tryint to parse a path. On the Windows machine I can look for lastIndexOf("\\"), but this doesn't work on a Linux box.
On a linux box, apparently I need to search for lastIndexOf("/").
Is there a built-in way of searching for either type of slash (assuming I'm really correct above) or do you just need to have an "if" statement to check and then use the "\\" or the "/" notation depending on the "if" result?
Thanks for anyone's reply or advice.
-- Mike
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike,
use java.io.File.pathSeparator
xyz.lastIndexOf( File.pathSeparator );
cb
 
Mike London
Ranch Hand
Posts: 1290
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, thanks!!!
Just what I needed.
-- Mike
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!