• Post Reply Bookmark Topic Watch Topic
  • New Topic

REPLACE \ WITH \\ IN A STRING  RSS feed

 
rajesh vasireddy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I was thinking something like....



Henry
 
rajesh vasireddy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • 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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!