In JDK 1.5 or earlier, IOException only has 2 constructors:
IOException() and IOException(String s).
So you can't pass a cause exception or throwable to these constructors. To do that, you will need to do something like this:
ZipException ze = new ZipException("Nested ZipException");
IOException e = new IOException("IOException with nested ZipException");
e.initCause(ze);
throw e;
In JDK 6, 2 additional constructors are added:
IOException(String s, Throwable cause)
IOException(Throwable cause)
So the following can compile and run fine in JDK 6 and later:
ZipException ze = new ZipException("Nested ZipException");
IOException e = new IOException(ze);
throw e;
but will fail to compile in JDK 1.5 or earlier:
c:\tmp > javac -version A.java
javac 1.5.0_06A.java:15: cannot find symbol
symbol : constructor IOException(java.util.zip.ZipException)
location: class java.io.IOException
IOException e = new IOException(ze);
^1 error
Subscribe to:
Post Comments (Atom)
Heroku Custom Trust Store for SSL Handshake
Working with Heroku for deploying apps (java, nodejs, etc..) is made very easy but while integrating one of the service ho...
-
Multi-Tenancy with the SaaS based model does not bring any change on the application layer as multiple services deployment of application w...
-
I have a class which is not serializable. If i will try to serialize the object of it than i am going to get exception "java.io.NotSer...
-
Raspberry Pi is an awesome and interesting . I was totally astonished after knowing about it from one of my friend and colleague "Ale...
No comments:
Post a Comment