source: josm/trunk/src/com/kitfox/svg/xml/cpx/CPXTest.java@ 8317

Last change on this file since 8317 was 8084, checked in by bastiK, 11 years ago

add svn:eol-style=native for svgsalamander

  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1/*
2 * SVG Salamander
3 * Copyright (c) 2004, Mark McKay
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or
7 * without modification, are permitted provided that the following
8 * conditions are met:
9 *
10 * - Redistributions of source code must retain the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer.
13 * - Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials
16 * provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 * OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * Mark McKay can be contacted at mark@kitfox.com. Salamander and other
32 * projects can be found at http://www.kitfox.com
33 *
34 * Created on February 12, 2004, 2:45 PM
35 */
36
37package com.kitfox.svg.xml.cpx;
38
39import com.kitfox.svg.SVGConst;
40import java.io.*;
41import java.util.logging.Level;
42import java.util.logging.Logger;
43
44/**
45 * @author Mark McKay
46 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
47 */
48public class CPXTest {
49
50 /** Creates a new instance of CPXTest */
51 public CPXTest() {
52
53// FileInputStream fin = new FileInputStream();
54 writeTest();
55 readTest();
56 }
57
58 public void writeTest()
59 {
60 try {
61
62 InputStream is = CPXTest.class.getResourceAsStream("/data/readme.txt");
63//System.err.println("Is " + is);
64
65 FileOutputStream fout = new FileOutputStream("C:\\tmp\\cpxFile.cpx");
66 CPXOutputStream cout = new CPXOutputStream(fout);
67
68 byte[] buffer = new byte[1024];
69 int numBytes;
70 while ((numBytes = is.read(buffer)) != -1)
71 {
72 cout.write(buffer, 0, numBytes);
73 }
74 cout.close();
75 }
76 catch (Exception e)
77 {
78 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
79 }
80 }
81
82 public void readTest()
83 {
84 try {
85
86// InputStream is = CPXTest.class.getResourceAsStream("/rawdata/test/cpx/text.txt");
87// InputStream is = CPXTest.class.getResourceAsStream("/rawdata/test/cpx/cpxFile.cpx");
88 FileInputStream is = new FileInputStream("C:\\tmp\\cpxFile.cpx");
89 CPXInputStream cin = new CPXInputStream(is);
90
91 BufferedReader br = new BufferedReader(new InputStreamReader(cin));
92 String line;
93 while ((line = br.readLine()) != null)
94 {
95 System.err.println(line);
96 }
97 }
98 catch (Exception e)
99 {
100 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
101 }
102 }
103
104 /**
105 * @param args the command line arguments
106 */
107 public static void main(String[] args)
108 {
109 new CPXTest();
110 }
111
112}
Note: See TracBrowser for help on using the repository browser.