This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Searching for Unix Slash  RSS feed

 
Mike London
Ranch Hand
Posts: 1476
10
  • 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: 1476
10
  • 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!