FileDocCategorySizeDatePackage
getMIMEHeader.javaAPI DocExample1041Thu Apr 03 15:26:20 BST 1997None

getMIMEHeader.java

import java.net.*;
import java.io.IOException;

public class getMIMEHeader {

  public static void main(String args[]) {

    for (int i=0; i < args.length; i++) {
      try {
        URL u = new URL(args[0]);
        URLConnection uc = u.openConnection();
        System.out.println("Content-type: " + uc.getContentType());
        System.out.println("Content-encoding: " + uc.getContentEncoding());
        System.out.println("Date: " + new java.util.Date(uc.getDate()));
        System.out.println("Last modified: " + new java.util.Date(uc.getLastModified()));
        System.out.println("Expiration date: " + new java.util.Date(uc.getExpiration()));
        System.out.println("Content-length: "   + uc.getContentLength());
      }  // end try
      catch (MalformedURLException e) {
        System.err.println(args[i] + " is not a URL I understand");
      }
      catch (IOException e) {
        System.err.println(e);
      }      
      System.out.println();
      
    }  // end for
      
  }  // end main

}  // end getMIMEHeader