really simple test for accessibility of a zip file (used to check for pathological...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 18 Sep 2007 10:24:42 +0000 (10:24 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 18 Sep 2007 10:24:42 +0000 (10:24 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@473 be28352e-c001-0410-b1a7-c7978e42abec

src/uk/ac/vamsas/test/simpleclient/ZipTest.java [new file with mode: 0644]

diff --git a/src/uk/ac/vamsas/test/simpleclient/ZipTest.java b/src/uk/ac/vamsas/test/simpleclient/ZipTest.java
new file mode 100644 (file)
index 0000000..0c6fa11
--- /dev/null
@@ -0,0 +1,34 @@
+package uk.ac.vamsas.test.simpleclient;\r
+\r
+import java.io.File;\r
+import java.util.jar.JarFile;\r
+/**\r
+ * really simple test to see if we can open an archive and test for the existence of\r
+ * an entry called vamssDocument.xml.\r
+ * \r
+ * 'Pathological' archives fail this test (due to things like funny characters or lots of '.' in the entry name.\r
+ * \r
+ * @author JimP\r
+ *\r
+ */\r
+public class ZipTest {\r
+\r
+  /**\r
+   * @param args single filename as an argument to open as a Jar file.\r
+   */\r
+  public static void main(String[] args) {\r
+    File av = new File(args[0]);\r
+    try {\r
+      JarFile jf = new JarFile(av, false, JarFile.OPEN_READ);\r
+      if (jf.getEntry("vamsasDocument.xml")!=null)\r
+      {\r
+        System.out.println("Valid archive "+av);\r
+      }\r
+      jf.close();\r
+    } catch (Exception f)\r
+    {\r
+      System.out.println("Couldn't access jar archive "+av);\r
+      f.printStackTrace(System.out);\r
+    }\r
+  }\r
+}\r