1 38 39 40 package com.sun.xml.fastinfoset.tools; 41 42 import java.io.BufferedInputStream ; 43 import java.io.BufferedOutputStream ; 44 import java.io.FileInputStream ; 45 import java.io.FileOutputStream ; 46 import java.io.InputStream ; 47 import java.io.OutputStream ; 48 import com.sun.xml.fastinfoset.CommonResourceBundle; 49 50 public abstract class TransformInputOutput { 51 52 53 public TransformInputOutput() { 54 } 55 56 public void parse(String [] args) throws Exception { 57 InputStream in = null; 58 OutputStream out = null; 59 if (args.length == 0) { 60 in = new BufferedInputStream (System.in); 61 out = new BufferedOutputStream (System.out); 62 } else if (args.length == 1) { 63 in = new BufferedInputStream (new FileInputStream (args[0])); 64 out = new BufferedOutputStream (System.out); 65 } else if (args.length == 2) { 66 in = new BufferedInputStream (new FileInputStream (args[0])); 67 out = new BufferedOutputStream (new FileOutputStream (args[1])); 68 } else { 69 throw new IllegalArgumentException (CommonResourceBundle.getInstance().getString("message.optinalFileNotSpecified")); 70 } 71 72 parse(in, out); 73 } 74 75 abstract void parse(InputStream in, OutputStream out) throws Exception ; 76 } 77 | Popular Tags |