aspose file tools*
The moose likes Beginning Java and the fly likes Urgent: how to remove ^M (newline) characters using Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Urgent: how to remove ^M (newline) characters using Java?" Watch "Urgent: how to remove ^M (newline) characters using Java?" New topic
Author

Urgent: how to remove ^M (newline) characters using Java?

Annie Zhang
Ranch Hand

Joined: Sep 08, 2004
Posts: 31
Does anyone know how to remove ^M (newline) characters using Java? Could you please show me the snippet? I am using java version 1.3, so I couldn't use java.util.regex.

Thanks a lot,
Annie
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Let's start with the "more typing" solution. There are shorter ones but this one will get you started. In this forum we often give broad hints and send you looking in the API for details ...


Look at the API docs for String to see if you can find "position of" and how to get the part of a string up to position i, the part of a string after position i. Take a shot at some code and let us see how it works.


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
Annie Zhang
Ranch Hand

Joined: Sep 08, 2004
Posts: 31
Thanks Stan for your reply. I was confused by the "^M" in the unix text file. After I replaced it with "\r\n", everything works now.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

perhaps native2ascii is a program for you?


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Urgent: how to remove ^M (newline) characters using Java?