summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorkitfox2007-07-18 17:54:46 +0200
committerkitfox2007-07-18 17:54:46 +0200
commit16d8eb9f09b92887d743f114455329811d7ee960 (patch)
treefce126ff8ba08d16bbff1e09ae773d77b8f66006 /src/test
parentPartially added inflationi of zipped files. (diff)
downloadsvg-salamander-core-16d8eb9f09b92887d743f114455329811d7ee960.tar.gz
svg-salamander-core-16d8eb9f09b92887d743f114455329811d7ee960.tar.xz
svg-salamander-core-16d8eb9f09b92887d743f114455329811d7ee960.zip
Added parsing of gzipped svg files.
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@41 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/kitfox/svg/zip/ZipTestMain.java76
-rw-r--r--src/test/res/missing.svgzbin0 -> 15968 bytes
2 files changed, 76 insertions, 0 deletions
diff --git a/src/test/java/com/kitfox/svg/zip/ZipTestMain.java b/src/test/java/com/kitfox/svg/zip/ZipTestMain.java
new file mode 100644
index 0000000..7192908
--- /dev/null
+++ b/src/test/java/com/kitfox/svg/zip/ZipTestMain.java
@@ -0,0 +1,76 @@
+/*
+ * ZipTestMain.java
+ *
+ * Created on July 18, 2007, 12:44 AM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.svg.zip;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.zip.GZIPInputStream;
+
+/**
+ *
+ * @author kitfox
+ */
+public class ZipTestMain
+{
+
+ /** Creates a new instance of ZipTestMain */
+ public ZipTestMain() throws IOException
+ {
+ URL url = ZipTestMain.class.getResource("/missing.svgz");
+// URL url = ZipTestMain.class.getResource("/AdamTagletClasses.svg");
+ InputStream is = url.openStream();
+ BufferedInputStream bin = new BufferedInputStream(is);
+
+ bin.mark(2);
+ int b0 = bin.read();
+ int b1 = bin.read();
+ bin.reset();
+
+ InputStreamReader reader;
+
+ //Check for gzip magic number
+ if ((b1 << 8 | b0) == GZIPInputStream.GZIP_MAGIC)
+ {
+ GZIPInputStream iis = new GZIPInputStream(bin);
+ reader = new InputStreamReader(iis);
+ }
+ else
+ {
+ //Plain text
+ reader = new InputStreamReader(bin);
+ }
+
+
+ BufferedReader br = new BufferedReader(reader);
+ for (String s = br.readLine(); s != null; s = br.readLine())
+ {
+ System.err.println(s);
+ }
+ }
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args)
+ {
+ try
+ {
+ new ZipTestMain();
+ } catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/test/res/missing.svgz b/src/test/res/missing.svgz
new file mode 100644
index 0000000..051d5e7
--- /dev/null
+++ b/src/test/res/missing.svgz
Binary files differ