Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to Capture New Line in JTextArea?

843806May 26 2008 — edited May 26 2008
I apologize if this is easy, but I've been searching here and the web for a few hours with no results.

I have a JTextArea on a form. I want to save the text to a database, including any newline characters - /n or /r/n - that were entered.

If I just do a .getText for the component, I can do a System.println and see the carriage return. However, when I store and then retrieve from the database, I get the lines concatenated.

How to I search for the newline character and then - for lack of a better idea - replace it with a \n or something similar?

TIA!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 23 2008
Added on May 26 2008
6 comments
573 views