Print MIME header : MIME « Network Protocol « Java






Print MIME header

  
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class MainClass {
  public static void main(String args[]) {
    URL u;
    URLConnection uc;
    String header;

    try {
      u = new URL("http://www.java2s.com");
      uc = u.openConnection();
      for (int j = 1;; j++) {
        header = uc.getHeaderField(j);
        if (header == null)
          break;
        System.out.println(uc.getHeaderFieldKey(j) + " " + header);
      }
    } catch (MalformedURLException e) {
      System.err.println("not a URL I understand.");
    } catch (IOException e) {
      System.err.println(e);
    }
  }

}

           
         
    
  








Related examples in the same category

1.MIME type mappings
2.A convenience class which handles conversions between MIME charset names and Java encoding names.
3.A utility class, which provides some MIME related application logic.
4.HTTP MIME Response
5.MIME types to use for various requests
6.Known mime types
7.Declaring MIME types to use for various requests and provide utility manipulation methods
8.Map file extensions to MIME types. Based on the Apache mime.types file
9.Frequently used MIME types
10.enum Mime Type
11.Mime type map
12.Mime Type