• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

REPLACE \ WITH \\ IN A STRING

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I AM TRYING TO REPLACE THE BACKSLASH(\) WITH (\\) IN THE STRING BELOW
C:\Program Files\Yahoo!\Messenger\Profiles\
I AM UNABLE TO DO...SO PLEASE HELP ME...........

THANKS IN ADVANCE
 
author
Posts: 23958
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rajesh vass wrote:Hi guys,
I AM TRYING TO REPLACE THE BACKSLASH(\) WITH (\\) IN THE STRING BELOW
C:\Program Files\Yahoo!\Messenger\Profiles\
I AM UNABLE TO DO...SO PLEASE HELP ME...........

THANKS IN ADVANCE




Well, what have you tried? Have you tried the replace() method? BTW, you do know that strings are immutable, and that the best you can do is create a new string (with replaced values), right?

Henry
 
Henry Wong
author
Posts: 23958
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Moving this topic to Java in General (beginner)...

Henry
 
rajesh vasireddy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

rajesh vass wrote:Hi guys,
I AM TRYING TO REPLACE THE BACKSLASH(\) WITH (\\) IN THE STRING BELOW
C:\Program Files\Yahoo!\Messenger\Profiles\
I AM UNABLE TO DO...SO PLEASE HELP ME...........

THANKS IN ADVANCE




Well, what have you tried? Have you tried the replace() method? BTW, you do know that strings are immutable, and that the best you can do is create a new string (with replaced values), right?

Henry



THIS IS THE PART OF CODE
yahooBasePath=properties.getProperty("YAHOOBASEPATH");
yahooBasePath1=properties.getProperty("YAHOOBASEPATH");

String[] tokens = yahooBasePath1.split("\\");
System.out.println(tokens[0]);
try
{
int len = tokens.length;
String url;
for (int i = 0; i <len; i++)
{
System.out.println(tokens[0] + tokens[len]);
url = tokens[i] + "\\\\";
}
System.out.println("url");

System.out.println("Propety Read :" + yahooBasePath);
}
catch (Exception e) { }
 
rajesh vasireddy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THIS IS THE PART OF CODE
yahooBasePath=properties.getProperty("YAHOOBASEPATH");
yahooBasePath1=properties.getProperty("YAHOOBASEPATH");

String[] tokens = yahooBasePath1.split("\\");
System.out.println(tokens[0]);
try
{
int len = tokens.length;
String url;
for (int i = 0; i <len; i++)
{
System.out.println(tokens[0] + tokens[len]);
url = tokens[i] + "\\\\";
}
System.out.println("url");
yahooBasePath =URL;

}
catch (Exception e) { }
 
Henry Wong
author
Posts: 23958
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I was thinking something like....



Henry
 
rajesh vasireddy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:
I was thinking something like....



Henry




HI HENRY..

I ALREADY GAVE THIS BUT IT IS SHOWING ERROR
 
Henry Wong
author
Posts: 23958
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rajesh vass wrote:
HI HENRY..

I ALREADY GAVE THIS BUT IT IS SHOWING ERROR



It works for me... care to elaborate what that ERROR is? And an example of what you did?

Henry
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rajesh vass wrote:
HI HENRY..

I ALREADY GAVE THIS BUT IT IS SHOWING ERROR



And KeepItDown will ya? All that yelling (caps) is a bit irritating.

Thanks
 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic