Results 1 to 5 of 5
  1. #1
    heartysnowy's Avatar
    heartysnowy is offline Member
    Join Date
    Nov 2008
    Posts
    37
    Rep Power
    0

    Default Replace "\" with "/"

    I have googled this issue but there is no an accurate answer for it.

    I tried the codes below but it doesn't work due to "/" slash.
    Java Code:
    	
    String sPath= txtSample1.getText().replace('\','/');
    Can any1 suggest me a solution for this ? :)

    Thanks and Regards,
    Hearty

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Have you tried
    Java Code:
    String sPath= txtSample1.getText().replace("\\","/");

  3. #3
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    Java Code:
    StringBuffer sb = new StringBuffer();
    //
    Pattern pattern = Pattern.compile("\\\\");
    Matcher matcher = pattern.matcher(sPath);
    // ?....
    while(matcher.find())
    {
        matcher.appendReplacement(sb,"/");
    }
    Tutorial

    It's early am, gotta go so sample code probably need work .....
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  4. #4
    heartysnowy's Avatar
    heartysnowy is offline Member
    Join Date
    Nov 2008
    Posts
    37
    Rep Power
    0

    Default

    Sorry for the late reply and thanks again masi for help and nicoloas too^^.

  5. #5
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Quote Originally Posted by heartysnowy View Post
    I have googled this issue but there is no an accurate answer for it.
    More fundamental question: Why do you want to do this? All known Java JVM's automatically handle it for you. There is no need to make this change.

Similar Threads

  1. Hwlp with "Open", "Save", "Save as..."
    By trill in forum New To Java
    Replies: 3
    Last Post: 11-02-2010, 10:26 AM
  2. Java, Military Format using "/" and "%" Operator!!
    By sk8rsam77 in forum New To Java
    Replies: 11
    Last Post: 02-26-2010, 04:03 AM
  3. Replies: 1
    Last Post: 10-20-2008, 08:35 AM
  4. <core:forEach var="" begin="+<%=j%>+">???
    By freddieMaize in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2008, 02:20 AM
  5. "Jumble" or "Scramble" Program
    By Shadow22202 in forum Java Applets
    Replies: 8
    Last Post: 04-30-2008, 04:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •