Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > long string

Reply
Thread Tools

long string

 
 
Dirk Bruere at NeoPax
Guest
Posts: n/a
 
      06-18-2009
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"

--
Dirk

 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      06-18-2009
Dirk Bruere at NeoPax wrote:
> 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";



 
Reply With Quote
 
 
 
 
Dirk Bruere at NeoPax
Guest
Posts: n/a
 
      06-18-2009
markspace wrote:
> Dirk Bruere at NeoPax wrote:
>> 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";


So I have to break it up and concatenate.
Thanks.

--
Dirk

http://www.transcendence.me.uk/ - Transcendence UK
http://www.theconsensus.org/ - A UK political party
http://www.onetribe.me.uk/wordpress/?cat=5 - Our podcasts on weird stuff
 
Reply With Quote
 
Gilbert Rebhan
Guest
Posts: n/a
 
      06-18-2009
Dirk Bruere at NeoPax schrieb:
> 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/ru...re-doc-or.html
http://blog.grayproductions.net/arti...tiline_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


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      06-19-2009
On Thu, 18 Jun 2009 19:40:10 +0100, Dirk Bruere at NeoPax
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who
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"

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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having compilation error: no match for call to (const __gnu_cxx::hash<long long int>) (const long long int&) veryhotsausage C++ 1 07-04-2008 05:41 PM
Use of Long and Long Long Bart C C Programming 27 01-15-2008 05:27 AM
long long and long Mathieu Dutour C Programming 4 07-24-2007 11:15 AM
unsigned long long int to long double Daniel Rudy C Programming 5 09-20-2005 02:37 AM
Assigning unsigned long to unsigned long long George Marsaglia C Programming 1 07-08-2003 05:16 PM



Advertisments