Skip to content

Java Source: ClassUtils.java

In my last post I mentioned that I would be sharing a useful utility class. This class is something I have implemented many times for different projects. Recently, while building up a library that I will be using in the near future, I implemented it for the umpteenth time. It struck me as a good idea to share it on the blog. So now, there is a new Shared Source category for the posts. That’s where I will post source code, that I find useful, from different languages.

ClassUtils provides several static methods that can be used to dynamically instantiate objects. Some may question the decision to return null rather than throw exceptions when an exception is thrown internally and the object cannot be instantiated. The way I usually use this class, it makes sense for me. If it doesn’t make sense for you, feel free to modify it so that it does.

Find the file here (opens in a new window): ClassUtils.java

Post a Comment

Your email is never published nor shared. Required fields are marked *