Convert String[] array to boolean[] array using Apache Commons

This code example shows how to convert a string array to a boolean array. For this we use the Apache Commons Beanutils library that comes with quite a few converters for different data types. It also comes with a utility class containing methods to do conversions without directly using the converter for that specific type. That utility class is called ConvertUtils and the below example shows how to use it to convert a string array to a boolean array.

Continue reading

Copy values from one Java object to another

If you want to copy values from one object instance to another that have (some or all) properties of the same name you can use the BeanUtils class in the Apache Commons Beanutils library to easily do just that. The BeanUtils method has a static method called copyProperties that takes two objects as parameters. The first is the destination object and the second is the origin object from which to copy the values. The method checks what properties are present in both objects and copy the values from the origin to the destination.

Continue reading