Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Finding the position of backslash character in a string

843835May 27 2003 — edited Feb 28 2008
Hi everyone,

I have a string which represents a file path.
Example:
String str = "C:\test\test.jsp";

I need to find the position of back-slash("\") characters in this string. Can anyone help me with this.

I tried doing by following methods:
(1) str.indexOf("\")
(2) Using ASCII Value of backslash and comparing that value to integer casted value of each character in string.

The first method returns error and second one doesnt returns anything.

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2008
Added on May 27 2003
20 comments
1,716 views