GeeCON Prague 2014*
The moose likes Java in General and the fly likes escape character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "escape character" Watch "escape character" New topic
Author

escape character

Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
Hi,
I am facing a problem where escape character getting printed.
String str = "first \n second";
expected output is
first
second
Assume that this string "str" is build by some other part of the program and on printing output i am getting is
first \n second
Please can anyone tell where i am going wrong.
Thanks in advance.
-arun


Sharing is learning
Philip Shanks
Ranch Hand

Joined: Oct 15, 2002
Posts: 189
It's just a hunch, but I would double check that the program that creates the string isn't actually creating it as "\\n". In that case the backslash character itself is being escaped to give a literal backslash.
PCS


Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
Biju Philip
Greenhorn

Joined: Nov 03, 2001
Posts: 7
Note sure if it's what you want, but here's the platform-independent way to do it:

-Biju
[ November 20, 2002: Message edited by: Biju Philip ]
 
GeeCON Prague 2014
 
subject: escape character