This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 19541
    
  16

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: 18108
    
  39

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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rtrim function in jdk 1.4
 
Similar Threads
initialising in arrys in form bean
JDBC with Oracle prob URGENT
The problem of JDK and WEBLOGIC
upgrade jdk to 5.0 in WSAD 5.1
What is the Difference between JDK 1.4, JDK 1.5 and JDK 1.6 ?