Add command map to Activation in Java

Description

The following code shows how to add command map to Activation.

Example


/*from  www. j  ava 2  s .co m*/
import javax.activation.CommandInfo;
import javax.activation.MailcapCommandMap;

public class Main {
  public static void main(String[] args) {
    MailcapCommandMap mailcapCommandMap = new MailcapCommandMap();
    String mailcap = "text/plain;; "
        + "x-java-content-handler=beans.TextHandler;"
        + "x-java-view=beans.TextViewer;"
        + "x-java-edit=beans.TextEditor";
    mailcapCommandMap.addMailcap(mailcap);
    // Get all MIME types
    String[] mimeTypes = mailcapCommandMap.getMimeTypes();
    for (String mimeType : mimeTypes) {
      System.out.println(mimeType);
      CommandInfo[] commandInfos = mailcapCommandMap
          .getAllCommands(mimeType);
      for (CommandInfo info : commandInfos) {
        System.out.println(" " + info.getCommandName() + " : "
            + info.getCommandClass());
      }
    }
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Development »




Java Algorithms
Java Clipboard
Java Compiler
Java Desktop
Java Virtual Machine
Java Math
OS
Random
Java Robot
Java RuntimeMXBean
Java Timer
Java UUID
Java Internationalization