File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to write Trim() method ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to write Trim() method ?" Watch "How to write Trim() method ?" New topic
Author

How to write Trim() method ?

amit_patel2786
Greenhorn

Joined: Apr 11, 2001
Posts: 10
Dear friends,
I know how to use trim() but in my project we been told to write a code which do the same job as trim(),
i tred it but it is not working, oooH,
we are not allowed to use trim()
if any one of you have any thing in mind about this then please write back to this DUM boy ..........lol
thanks for your time
Amit
Art Metzer
Ranch Hand

Joined: Oct 31, 2000
Posts: 241
Why are you forbidden from using trim()? If you need to use trim(), use it, if you can't, there are lots of programming languages out there besides Java.
Sorry, small rant there, A.P. It's nothing personal, but I'm joining the growing hordes of people who have problems with requests like, "Hi, I need to use Java to store text in a variable? But I can't use Strings. Please help, URGENT."
If it helps you, though, amit_patel2786, here is the actual code for trim() from java.lang.String:

Maybe you can tweak this code to perform as you'd like it to.
Art
[This message has been edited by Art Metzer (edited April 20, 2001).]
Michael Hildner
Ranch Hand

Joined: Oct 13, 2000
Posts: 297
Art, it sounds like an exercise. Actually it might be fun to try to write a trim() method (without looking at src.jar).
amit_patel2786
Greenhorn

Joined: Apr 11, 2001
Posts: 10
Dear Art Metzer,
Thanks for the code, i know that i can use many other languages for this trim(), but when u get project from the open university and when they say that by using java and without using the actual trim() method how can u use any other language ? or can use just trim() method ?
hope u understand the problem ?
it is not that hard for the person like u how knows how to do trim() !
many thanks for the code !
Good day
Amit
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
amit_patel2786,
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at "JavaRanch Naming Policy" . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to write Trim() method ?