aspose file tools
The moose likes Beginning Java and the fly likes Removing linefeed from String. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Removing linefeed from String." Watch "Removing linefeed from String." New topic
Author

Removing linefeed from String.

Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 244
I want to remove linefeed character from String.

String = new String ("This is a line.

"
What I need in String is
Only one line "THis is a line"

How do I do this.

Thanks!
Gemini
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
If the newline(s) are on the end, the normal trim() will remove whitespace, including line feeds and tabs. If they are in the middle you can use String.replace("\n", " ") to convert them to blanks, which avoids running words together that used to be on different lines. See if either of those do what you need.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Removing linefeed from String.
 
Similar Threads
Please HELP Socket Amateur!
reading variable block file
why it doesnt output "Nice to meet you too!"?
How does copy from code samples work?
K&B Study Guide for Java 5 p498 Selftest problem 1