File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Multiline Strings 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 » Beginning Java
Bookmark "Multiline Strings" Watch "Multiline Strings" New topic

Multiline Strings

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Hi all,
I just wanted to know whether is it possible to have a multiline String with the end quote in a saperate line.

String j = "Multiline
Like this";
Thank you very much. (with out the concatanation)

SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
But you can put new-lines into Strings. Get the platform-dependent new-line String from line.separator. Add this into the String at the desired places.

People do use "\n" for new-line, but that's not strictly portable.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
David Han

Joined: Nov 27, 2004
Posts: 1
Good!I see. Thanks,Peter.
It is sorta covered in the JavaRanch Style Guide.
subject: Multiline Strings
Similar Threads
Escape sequence for multiline comments
Finding Multiple patterns from a multiline text using regex
Regular Expression: finding multiple lines
Need help in regex .Difference between PATTERN.DOTALL and PATTERN.MULTILINE
printing multiple line string