1 package uk.ac.vamsas.test.simpleclient;
\r
4 import java.util.jar.JarFile;
\r
6 * really simple test to see if we can open an archive and test for the existence of
\r
7 * an entry called vamssDocument.xml.
\r
9 * 'Pathological' archives fail this test (due to things like funny characters or lots of '.' in the entry name.
\r
14 public class ZipTest {
\r
17 * @param args single filename as an argument to open as a Jar file.
\r
19 public static void main(String[] args) {
\r
20 File av = new File(args[0]);
\r
21 boolean jfailed=false;
\r
23 JarFile jf = new JarFile(av, false, JarFile.OPEN_READ);
\r
24 if (jf.getEntry("vamsasDocument.xml")!=null)
\r
26 System.out.println("Valid archive "+av);
\r
30 } catch (Exception f)
\r
32 System.out.println("Couldn't access jar archive "+av);
\r
33 f.printStackTrace(System.out);
\r
36 System.out.println("Trying the Apache Zip Package:");
\r
37 org.apache.tools.zip.ZipFile jf = new org.apache.tools.zip.ZipFile(av);
\r
38 if (jf.getEntry("vamsasDocument.xml")!=null)
\r
40 System.out.println("Valid archive "+av);
\r
43 } catch (Exception f)
\r
45 System.out.println("Couldn't access jar archive "+av);
\r
46 f.printStackTrace(System.out);
\r