1 10 import java.io.*; 11 import java.beans.*; 12 import com.sun.activation.registries.*; 13 import javax.activation.*; 14 15 public class MCTest { 16 MailcapCommandMap mcf = null; 17 String file_name = null; 18 19 public static void main(String args[]){ 20 MCTest test = new MCTest(); 21 22 if(args.length == 0) { 23 System.out.println("usage: MCTest mailcap"); 24 System.exit(1); 25 } 26 27 test.setFile(args[0]); 28 29 test.doit(); 30 31 } 32 33 private void setFile(String fname) { 34 file_name = fname; 35 } 36 37 private void doit() { 38 39 try { 40 mcf = new MailcapCommandMap(file_name); 41 } catch (Exception e){ 42 e.printStackTrace(); 43 System.exit(1); 44 } 45 46 CommandInfo cmdinfo[] = mcf.getAllCommands("text/plain"); 47 System.out.print("Are there any commands for text/plain?"); 48 49 if(cmdinfo != null) { 50 System.out.println("number of cmds = " + cmdinfo.length); 51 System.out.println("now try an individual cmd"); 52 CommandInfo info = mcf.getCommand("text/plain", "view"); 53 if(info != null) { 54 System.out.println("Got command..."); 55 } 56 else 57 System.out.println("no cmds"); 58 60 mcf.addMailcap("text/plain;; x-java-flobotz=com.sun.activation.flobotz\n"); 61 if(cmdinfo != null) { 63 cmdinfo = mcf.getAllCommands("text/plain"); 64 System.out.println("now we have cmds = " + cmdinfo.length); 65 66 } 67 68 } else { 69 System.out.println("NO CMDS AT ALL!"); 70 } 71 72 } 73 74 } 75 | Popular Tags |