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
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.
I agree. Here's the link:
subject: Multiline Strings
It's not a secret anymore!