This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to split

 
Saurabh Naik
Ranch Hand
Posts: 87
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose this is mystring = c:\my\you\image.jpg

and I want only image.jpg.

so I hav used mystring.split("\") or ("\\");

but its giving me exception java.util.regex.patternsyntaxexception: Unexpected internal error near index 1 \^
 
Sagar Rohankar
Ranch Hand
Posts: 2905
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saurabh Naik wrote:suppose this is mystring = c:\my\you\image.jpg

and I want only image.jpg.


If you want only name of the file, then I suggest don't go for split method, instead use String#subString(int, int0 method, the first parameter is the index of last "\"(String has a method for this, search Java Docs) and second param is length of string.

HTH
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic