001// StreamDemo.java: demonstration application showing Æfred's event stream. 002// NO WARRANTY! See README, and copyright below. 003// $Id$ 004// Modified 11/8/98 to add package statement. 005package com.microstar.xml.demo; 006 007import java.io.FileInputStream; 008import java.io.InputStream; 009 010import com.microstar.xml.XmlParser; 011 012/** 013 * Demonstration application showing Æfred's event stream from a stream. 014 * <p>Usage: <code>java StreamDemo</code> 015 * @author Copyright (c) 1998 by Microstar Software Ltd.; 016 * @author written by David Megginson <dmeggins@microstar.com> 017 * @version 1.1 018 * @since Ptolemy II 0.2 019 * @see com.microstar.xml.XmlParser 020 * @see com.microstar.xml.XmlHandler 021 * @see XmlApp 022 * @see EventDemo 023 */ 024public class StreamDemo extends EventDemo { 025 public static void main(String[] args) throws Exception { 026 StreamDemo handler = new StreamDemo(); 027 InputStream is = null; 028 029 if (args.length != 1) { 030 System.err.println("Usage: java StreamDemo <file>"); 031 System.exit(1); 032 } 033 034 try { 035 is = new FileInputStream(args[0]); 036 037 XmlParser parser = new XmlParser(); 038 parser.setHandler(handler); 039 parser.parse(makeAbsoluteURL(args[0]), null, is, null); 040 } finally { 041 if (is != null) { 042 try { 043 is.close(); 044 } catch (Throwable throwable) { 045 System.out.println("Failed to close '" + args[0] + "'"); 046 throwable.printStackTrace(); 047 } 048 } 049 } 050 } 051}