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 Beginning Java and the fly likes escape sequences 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 » Beginning Java
Reply Bookmark "escape sequences" Watch "escape sequences" New topic
Author

escape sequences

Ronald Whalen
Ranch Hand

Joined: Mar 27, 2001
Posts: 38
Hi! Got a simple question. I am trying to print text to file. I am having trouble with this line:
out.println("errorMsg += \"'\n''\n'\"+(errCount+1)+\". Name not specified\";");
I keep getting new lines in the text file rather than having \n print out twice. I thought that placing it in single quotes would allow for the character literals to print out rather than the new line. any help would be appreciated.

Thanks!
Ronald
Roy Tock
Ranch Hand

Joined: Jul 16, 2001
Posts: 83
Rather than use '\n', have you tried \\n?
This code:

yields this output:
C:\Temp>java Trial
errorMsg += "\n\n"+(errCount+1)+". Name not specified";
C:\Temp>
Ronald Whalen
Ranch Hand

Joined: Mar 27, 2001
Posts: 38
Thanks for the reply. Tried that too. Finally got it to work by using the concat operator to break up the string along the lines of
..+"\\"+"n"+
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: escape sequences
 
Similar Threads
How to read each line from file in Shell script
How to print JTable with multi-line header?
Writing a file and executing
New Line Character not recognized
cgi applet communication problems