aspose file tools*
The moose likes Beginning Java and the fly likes Storing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Storing "new line character " in a string" Watch "Storing "new line character " in a string" New topic
Author

Storing "new line character " in a string

Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
I need to store
String S ="name
city
zip"
in as string
Can someone suggest me way to do this.
thanks
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Gemini Moses:
I need to store
String S ="name
city
zip"
in as string
Can someone suggest me way to do this.
thanks

String S = "name\ncity\nzip";
Might be different on Diferent OS's.


GenRocket - Experts at Building Test Data
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Thanks for quick response.
However this is not solving my problem.
How can I store an "Enter character" in String for NT.
Thanks!!
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

\n is the new line character. What exactly are you trying to acheive?
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4462
    
    6

Originally posted by Gemini Moses:
However this is not solving my problem.
How can I store an "Enter character" in String for NT. Thanks!!


I would think the solution Gregg gave works in any OS, including NT if you pass the String to System.out.println(). What exactly would "solving your problem" entail? What are you trying to do?
Junilu
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Hello,
It works for me. But of course only at the console (eg System.out.println("name\ncity\nzip")). You can't do it this way drawing to an Applet (or Panel). And sorry to say, I don't think it's possible (I'm pretty sure I read that once).
Good Luck,
-Dirk Schreckmann


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Now that's service! Three responses at once.
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Thanks everyone!!!
I got busy in some other stuff yesterday and did not get time at all to check on this.
I am sorry. It did work the way it is supposed to work. But my problem is solved with some other way.
Thanks once again to all of you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing "new line character " in a string