Code example for CharArrayWriter

Methods: toCharArray

0
			throws Throwable { 
		try { 
			return (method.invoke(obj, args));
		} catch (InvocationTargetException err) {
			Throwable e = err.getTargetException();
			CharArrayWriter writer = new CharArrayWriter();
			e.printStackTrace(new PrintWriter(writer));
			JFrame frm = null;
			if (JFrame.getFrames().length > 0) { 
				frm = (JFrame) JFrame.getFrames()[0];
			} 
			JOptionPane.showMessageDialog(frm, e.getClass().getName() + ": "
					+ e.getMessage() + "\n" + new String(writer.toCharArray()),
					"Exception", JOptionPane.ERROR_MESSAGE); 
			throw (e);
		} 
	} 
}