my code stock.com

Snippet options

Download: Download snippet as untitled.java.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

public static void showProperty(Object obj) {
		try {
			if (obj.getClass().isArray()) {
				for (Object o : (Object[]) obj){
					showProperty(o);
				}
			} else {
				System.out.println(obj.getClass() + ", " + obj.toString());
				Method[] methods = obj.getClass().getMethods();
				for (Method m : methods) {
					String methodName = m.getName();
					if(m.getModifiers()==Modifier.PUBLIC 
							&& m.getParameterTypes().length==0 
							&& m.getReturnType()!=void.class 
							&& methodName.matches("^(is|get|can|length|lastModified|size).*$")){
						String result = String.valueOf(m.invoke(obj, new Object[]{}));
						if(result.indexOf("\r\n")>=0){
							result = result.substring(0, result.indexOf("\r\n")) + " ... (" + result.length() + ")";
						}else if(result.indexOf('\n')>=0){
							result = result.substring(0, result.indexOf("\n")) + " ... (" + result.length() + ")";
						}else if(result.indexOf('\r')>=0){
							result = result.substring(0, result.indexOf("\r")) + " ... (" + result.length() + ")";
						}else if(result.length() > 100){
							result = result.substring(0, 100) + " ... (" + result.length() + ")";
						}
						System.out.printf(" %-20s : %s\n", methodName, result);
					}
				}
				System.out.println();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.