aspose file tools*
The moose likes Beginning Java and the fly likes rtrim function in jdk 1.4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "rtrim function in jdk 1.4" Watch "rtrim function in jdk 1.4" New topic
Author

rtrim function in jdk 1.4

sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
Hi,

Currently i am using jdk 1.4.
I want to remove new line character and carriage return from the end of the String. Do we have the functionality of rtrim in java?
I dont want to remove any leading spaces.

thanks
sudha
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

There isn't just rtrim, but it's not too hard to do yourself:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

I want to remove new line character and carriage return from the end of the String. Do we have the functionality of rtrim in java?


Regex will also work here...



And this is the equivalent of Rob's solution...



Henry

Note: code not tested


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: rtrim function in jdk 1.4