This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: escape character
 
Similar Threads
remove carriage return from string
New line in quoted string
replacee / with \
New line problem
StringTokenizer does not work properly.