FileDocCategorySizeDatePackage
Handler.javaAPI DocExample759Thu Apr 03 15:27:18 BST 1997None

Handler.java

import java.net.*;
import java.io.*;
import java.util.*;

public class Handler extends java.net.URLStreamHandler {

  protected URLConnection openConnection(URL u) throws IOException {
    return new mailtoURLConnection(u);
  }

  protected void parseURL(URL u, String spec, int start, int limit) {
  
    StringTokenizer st = new StringTokenizer(spec.substring(start), ":@", false);
    String protocol = st.nextToken(); // should be mailto
    String file = st.nextToken();  // really the username
    String host = st.nextToken();
    String ref = null;
    int port = 25;
        
    setURL(u, protocol, host, port, file, ref);
    
   }

  protected String toExternalForm(URL u) {
  
    return "mailto:" + u.getFile() + "@" + u.getHost();;
    
  }

}