Archive for Java

Java Exceptions Subclass

Sunday, April 17th, 2011

Exceptions subclass in java which can be throwable in try catch finally block.

This is example of Exceptions subclass. Java se 6 supports following exceptions

 

AclNotFoundException ActivationException
AlreadyBoundException ApplicationException
AWTException BackingStoreException
BadAttributeValueExpException BadBinaryOpValueExpException
BadLocationException BadStringOperationException
BrokenBarrierException CertificateException
ClassNotFoundException CloneNotSupportedException
DataFormatException DatatypeConfigurationException
DestroyFailedException ExecutionException
ExpandVetoException FontFormatException
GeneralSecurityException GSSException
IllegalAccessException IllegalClassFormatException
InstantiationException InterruptedException
IntrospectionException InvalidApplicationException
InvalidMidiDataException InvalidPreferencesFormatException
InvalidTargetObjectTypeException InvocationTargetException
IOException JAXBException
JMException KeySelectorException
LastOwnerException LineUnavailableException
MarshalException MidiUnavailableException
MimeTypeParseException MimeTypeParseException
NamingException NoninvertibleTransformException
NoSuchFieldException NoSuchMethodException
NotBoundException NotOwnerException
ParseException ParserConfigurationException
PrinterException PrintException
PrivilegedActionException PropertyVetoException
RefreshFailedException RemarshalException
RuntimeException SAXException
ScriptException ServerNotActiveException
SOAPException SQLException
TimeoutException TooManyListenersException
TransformerException TransformException
UnmodifiableClassException UnsupportedAudioFileException
UnsupportedCallbackException UnsupportedFlavorException
UnsupportedLookAndFeelException URIReferenceException
URISyntaxException UserException
XAException XMLParseException
XMLSignatureException XMLStreamException
XPathException  

ExceptionExample.java

import java.io.IOException;
public class ExceptionExample {

	public static void main(String[] args) {

		try
		{
			// IO statements
		}
		catch(IOException io)
		{
			io.printStackTrace();
		}
		catch(Exception e)
		{
		    e.printStackTrace();
		}
		finally
		{
			// this block run in both cases
			// if error come or not come
		}
	}

}