001 /*
002 * CPXTest.java
003 *
004 *
005 * The Salamander Project - 2D and 3D graphics libraries in Java
006 * Copyright (C) 2004 Mark McKay
007 *
008 * This library is free software; you can redistribute it and/or
009 * modify it under the terms of the GNU Lesser General Public
010 * License as published by the Free Software Foundation; either
011 * version 2.1 of the License, or (at your option) any later version.
012 *
013 * This library is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016 * Lesser General Public License for more details.
017 *
018 * You should have received a copy of the GNU Lesser General Public
019 * License along with this library; if not, write to the Free Software
020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021 *
022 * Mark McKay can be contacted at mark@kitfox.com. Salamander and other
023 * projects can be found at http://www.kitfox.com
024 *
025 * Created on February 12, 2004, 2:45 PM
026 */
027
028 package com.kitfox.svg.xml.cpx;
029
030 import java.io.*;
031 import java.net.*;
032
033 /**
034 * @author Mark McKay
035 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
036 */
037 public class CPXTest {
038
039 /** Creates a new instance of CPXTest */
040 public CPXTest() {
041
042 // FileInputStream fin = new FileInputStream();
043 writeTest();
044 readTest();
045 }
046
047 public void writeTest()
048 {
049 try {
050
051 InputStream is = CPXTest.class.getResourceAsStream("/data/readme.txt");
052 //System.err.println("Is " + is);
053
054 FileOutputStream fout = new FileOutputStream("C:\\tmp\\cpxFile.cpx");
055 CPXOutputStream cout = new CPXOutputStream(fout);
056
057 byte[] buffer = new byte[1024];
058 int numBytes;
059 while ((numBytes = is.read(buffer)) != -1)
060 {
061 cout.write(buffer, 0, numBytes);
062 }
063 cout.close();
064 }
065 catch (Exception e)
066 {
067 e.printStackTrace();
068 }
069 }
070
071 public void readTest()
072 {
073 try {
074
075 // InputStream is = CPXTest.class.getResourceAsStream("/rawdata/test/cpx/text.txt");
076 // InputStream is = CPXTest.class.getResourceAsStream("/rawdata/test/cpx/cpxFile.cpx");
077 FileInputStream is = new FileInputStream("C:\\tmp\\cpxFile.cpx");
078 CPXInputStream cin = new CPXInputStream(is);
079
080 BufferedReader br = new BufferedReader(new InputStreamReader(cin));
081 String line;
082 while ((line = br.readLine()) != null)
083 {
084 System.err.println(line);
085 }
086 }
087 catch (Exception e)
088 {
089 e.printStackTrace();
090 }
091 }
092
093 /**
094 * @param args the command line arguments
095 */
096 public static void main(String[] args) {
097 new CPXTest();
098 }
099
100 }