The Artima Developer Community
Sponsored Link

Java Buzz Forum
Commons is your friend

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic    
Flat View: This topic has 0 replies on 1 page
Padraic R

Posts: 24
Nickname: prenagha
Registered: Sep, 2002

Padraic is a Java system architect
Commons is your friend Posted: Jun 7, 2003 8:11 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Padraic R.
Original Post: Commons is your friend
Feed Title: plog
Feed URL: http://sedoparking.com/search/registrar.php?domain=®istrar=sedopark
Feed Description: Padraic Renaghan's musings about (mostly) java software development
Latest Java Buzz Posts
Latest Java Buzz Posts by Padraic R
Latest Posts From plog

Advertisement
Had a task yesterday to strip formatting characters from a string prior to loading in a database. Figured that was a common function that would either be in the Java String class or some other widely available 3rd party class library. Browsed over to the Apache Commons Project and found exactly what I needed. CharSetUtils with the Lang subproject provides a handy delete from string function as well as other useful utility methods. Have a look for yourself at the Lang subproject and the other Commons subprojects as well -- seems like exactly the kind of drop in library we should all become familiar with to keep ourselves from re-inventing the type of utility classes that seem to be required on every Java development project.

Note: Spent some time trying to debug why this code snippet wouldn't work for removing the dash character from within a formatted phone number:

String cleanPhone = CharSetUtils.delete(phone, " +-()")

Turns out the 2nd argument is really a pattern, and "-" is a special character in that pattern indicating a range, so stripping "-" seems impossible with that class - no way to escape the char that I could find. Nevertheless a useful set of methods.

Read: Commons is your friend

Topic: ctl+shift+v in IDEA Previous Topic    

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use