really simple test for accessibility of a zip file (used to check for pathological...
[vamsas.git] / src / uk / ac / vamsas / test / simpleclient / ZipTest.java
1 package uk.ac.vamsas.test.simpleclient;\r
2 \r
3 import java.io.File;\r
4 import java.util.jar.JarFile;\r
5 /**\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
8  * \r
9  * 'Pathological' archives fail this test (due to things like funny characters or lots of '.' in the entry name.\r
10  * \r
11  * @author JimP\r
12  *\r
13  */\r
14 public class ZipTest {\r
15 \r
16   /**\r
17    * @param args single filename as an argument to open as a Jar file.\r
18    */\r
19   public static void main(String[] args) {\r
20     File av = new File(args[0]);\r
21     try {\r
22       JarFile jf = new JarFile(av, false, JarFile.OPEN_READ);\r
23       if (jf.getEntry("vamsasDocument.xml")!=null)\r
24       {\r
25         System.out.println("Valid archive "+av);\r
26       }\r
27       jf.close();\r
28     } catch (Exception f)\r
29     {\r
30       System.out.println("Couldn't access jar archive "+av);\r
31       f.printStackTrace(System.out);\r
32     }\r
33   }\r
34 }\r