1 10 11 import java.awt.*; 12 import java.beans.*; 13 import java.net.*; 14 import javax.activation.*; 15 16 public class FileView { 17 private Frame frame; 18 19 public static void main(String args[]) throws Exception { 20 FileView fv = new FileView(); 21 if (args.length == 0) { 22 System.out.println("usage: FileView file.txt"); 23 System.exit(1); 24 } 25 fv.view(args[0]); 26 } 27 28 private void view(String filename) throws Exception { 29 FileDataSource fds = new FileDataSource(filename); 30 DataHandler dh = new DataHandler(fds); 31 35 CommandInfo bi = dh.getCommand("view"); 36 37 if (bi == null) { 38 System.out.println("no viewer found, exiting"); 39 System.exit(1); 40 } 41 42 frame = new Frame("Viewer"); 43 frame.add((Component)dh.getBean(bi)); 44 frame.setSize(new Dimension(400,300)); 45 frame.show(); 46 } 47 } 48 | Popular Tags |