Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 7th, 2005, 09:25 AM
poornima poornima is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Bangalore
Posts: 3 poornima User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 5 sec
Reputation Power: 0
Replace "\" with "/" in Java

Can anybody please help me in replacing the "\" value as "/".
eg: str1\str2\str3

should get as str1/str2/str3

Please explain with a sample code

Thanking You in advance

Reply With Quote
  #2  
Old June 7th, 2005, 02:23 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
Try the replace method of the String class.
The following is off the top of my head, and untested.

Code:
String tmp = new String("str1\\str2\\str3");
tmp = tmp.replace('\\', '/');


It's fairly straightforward and needs no explanation.

Reply With Quote
  #3  
Old September 20th, 2007, 07:15 AM
yinminnu yinminnu is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Location: myanmar
Posts: 1 yinminnu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 37 m 10 sec
Reputation Power: 0
Send a message via Google Talk to yinminnu
Quote:
Originally Posted by poornima
Can anybody please help me in replacing the "\" value as "/".
eg: str1\str2\str3

should get as str1/str2/str3

Please explain with a sample code

Thanking You in advance



Hi! I am new member and I think you have solved that problem now!it's 2 years over now ! I sent it for others!everyone can try like this!

Code:
public static String backlashReplace(String myStr){
    final StringBuilder result = new StringBuilder();
    final StringCharacterIterator iterator = new StringCharacterIterator(myStr);
    char character =  iterator.current();
    while (character != CharacterIterator.DONE ){
     
      if (character == '\\') {
         result.append("/");
      }
       else {
        result.append(character);
      }

      
      character = iterator.next();
    }
    return result.toString();
  }

Last edited by MadCowDzz : September 24th, 2007 at 12:20 PM. Reason: added [code] tags

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Replace "\" with "/" in Java


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap