long string

  • Thread starter Dirk Bruere at NeoPax
  • Start date
D

Dirk Bruere at NeoPax

I have a requirement to define a longish (100+ char) string.
How do I define it without having to put everything on the same line ie
how can I break up the data to multiline format eg

String myString = "abcdigigboasaeasvd
ndjfvlggilugiugigf"
 
M

markspace

Dirk said:
I have a requirement to define a longish (100+ char) string.
How do I define it without having to put everything on the same line ie
how can I break up the data to multiline format eg

String myString = "abcdigigboasaeasvd
ndjfvlggilugiugigf"

String myString = "abcdigigboasaeasvd" +
"ndjfvlggilugiugigf";
 
G

Gilbert Rebhan

Dirk said:
I have a requirement to define a longish (100+ char) string.
How do I define it without having to put everything on the same line ie
how can I break up the data to multiline format eg

String myString = "abcdigigboasaeasvd
ndjfvlggilugiugigf"

If you need soemthing like heredoc in java you may use =

Jruby
http://blog.jayfields.com/2006/12/ruby-multiline-strings-here-doc-or.html
http://blog.grayproductions.net/articles/working_with_multiline_strings
http://snipplr.com/view/5432/ruby-heredoc-tricks/


or Groovy which has a """ multiline String , f.e.
String itext ="""This is another multiline String
that takes up a few lines.

Heredocs are different than Java Strings
in a few important ways:
1. They
preserve
newlines.

2. You don't have to "escape" internal quotes.
"""



within your Java code.

Regards, Gilbert
 
R

Roedy Green

I have a requirement to define a longish (100+ char) string.
How do I define it without having to put everything on the same line ie
how can I break up the data to multiline format eg

String myString = "abcdigigboasaeasvd"
+ "ndjfvlggilugiugigf"

The concatenation is done at compile time and hence has no run-time
penalty.
--
Roedy Green Canadian Mind Products
http://mindprod.com

If everyone lived the way people do in Vancouver, we would need three more entire planets to support us.
~ Guy Dauncey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top