AdvancedString – java.lang.String on steroids!

Every need an additional method on the String Class?  Well I have and it would have made life much easier.  Unfortunately you can’t subclass String as it is Final.  So what are you to do?  Well you wrap the String class.  I have created AdvancedString, which contains additional functionality and does a complete wrap.  You can easily subclass it if you wish.  I have added these additional abilities to AdvancedString:

  • containsHTML() – returns true if the string contains HTML
  • paragraphFormat() – formats the string to a width of X and enters line feeds.
  • removeHTML()

I didn’t need to add many new methods, and I certainly could have created these as utility classes or methods.  However I wanted to be able to have a single class and one that I could expand when I wanted to in the future.  So I created AdvancedString, while it wraps the String class, all returns are converter from String / String[] to AdvancedString / AdvancedString[].  Once you start using this, it’s just like using String.

Here is my example:


If you come up with any cool enhancements please share them back here!

  • Ghostprogrammer
  • I am known for being able to quickly decipher difficult problems to assist development teams in producing a solution. I have been called upon to be the Team Lead for multiple large-scale projects. I have a keen interest in learning new technologies, always ready for a new challenge.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: