This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes escape character Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: escape character
 
Similar Threads
replacee / with \
New line problem
New line in quoted string
StringTokenizer does not work properly.
remove carriage return from string