View Javadoc
1 2 package jsdsi.sexp; 3 4 import java.io.ByteArrayInputStream; 5 import java.io.ByteArrayOutputStream; 6 import java.io.EOFException; 7 import java.io.FileInputStream; 8 import java.io.ObjectInputStream; 9 import java.io.ObjectOutputStream; 10 11 import jsdsi.Obj; 12 13 /*** 14 * Parses S-expressions into SPKI/SDSI objects. 15 * 16 * @author Sameer Ajmani 17 * @version $Revision: 1.1.6.1 $ $Date: 2005/11/08 03:12:52 $ 18 */ 19 public class Parser { 20 public static void main(String[] args) throws Exception { 21 if (args.length < 1) { 22 System.err.println("usage: java Parser input-file"); 23 return; 24 } 25 ObjInputStream is = new ObjInputStream(new FileInputStream(args[0])); 26 ObjOutputStream os = new ObjOutputStream(System.out); 27 28 int i = 0; 29 try { 30 while (true) { 31 Obj o = is.readObj(); 32 //+debug 33 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 34 ObjectOutputStream oos = new ObjectOutputStream(bos); 35 Sexp s = o.toSexp(); 36 oos.writeObject(s); 37 oos.flush(); 38 s = 39 (Sexp) (new ObjectInputStream(new ByteArrayInputStream(bos 40 .toByteArray()))) 41 .readObject(); 42 //-debug 43 os.writeReadable(o, 0, 76, 0); 44 os.write('\n'); 45 i++; 46 } 47 } catch (SexpParseException e) { 48 System.err.println("sexp #" + i); 49 throw e; 50 } catch (EOFException e) { 51 os.flush(); 52 System.err.println("done"); 53 } 54 } 55 }

This page was automatically generated by Maven