Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4482901

constructors for JarFile throws unspecified Exception

XMLWordPrintable

    • beta2
    • sparc
    • solaris_2.6
    • Verified



      Name: auR10023 Date: 07/23/2001



      Constructors for java.util.jar.JarFile throws java.util.ZipException
      instead of FileNotFoundException. The javadoc says:
      ...
      public JarFile(String name)
              throws IOException

           Creates a new JarFile to read from the specified file name. The JarFile will
           be verified if it is signed.

           Parameters:
                name - the name of the JAR file to be opened for reading
           Throws:
                FileNotFoundException - if the file could not be found
                IOException - if an I/O error has occurred
                SecurityException - if access to the file is denied by the
                SecurityManager
      ...


      Here is the example:

      -------------t.java-------------
      import java.io.*;
      import java.util.*;
      import java.util.jar.*;

      public class t {
          public static void main (String args[]) {
              File file = new File("nonexist.jar");
              String fileName = file.getPath();
              JarFile jarFile = null;

              try {
                  jarFile = new JarFile(file, true);
              }
              catch (FileNotFoundException fe) {
                  System.out.println("OKAY");
                  return;
              }
              catch (IOException e) {
                  System.out.println("unexpected IOException: " + e);
                  return;
              }
          }
      }

      #java -version
      java version "1.4.0-beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b69)
      Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b69, mixed mode)

      #java t

      unexpected IOException: java.util.zip.ZipException: No such file or directory

      ======================================================================

            kkladkosunw Konstantin Kladko (Inactive)
            avusunw Avu Avu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: