Mega Code Archive

 
Categories / Java Tutorial / Development
 

Determine beans property type

import org.apache.commons.beanutils.PropertyUtils; public class Main {   public static void main(String[] args) throws Exception {     Recording recording = new Recording();     recording.setTitle("Magical Mystery Tour");     Class type = PropertyUtils.getPropertyType(recording, "title");     System.out.println("type = " + type.getName());     String value = (String) PropertyUtils.getProperty(recording, "title");     System.out.println("value = " + value);   } }