URLConnection getFileNameMap Example

URLConnection class getFileNameMap example. This example shows you how to use getFileNameMap method.


URLConnection class getFileNameMap example. public static FileNameMap getFileNameMap() Loads filename map (a mimetable) from a data file. It will first try to load the user-specific table, defined by "content.types.user.table" property. If that fails, it tries to load the default built-in table at lib/content-types.properties under java home.

Here is the code
/*
 * @ # GetFileNameMap
.java
 * A class repersenting use to g
etFileNameMap
 * method of URLConnection class in java.net package
 * version 23 June 2008
 * author Rose India 
 */

import java.net.*;

public class GetFileNameMap {

    public static void main(String args[]) throws Exception {
        SocketAddress socketAddress =
                new InetSocketAddress("192.168.10.80"9090);
        Proxy proxy = new Proxy(Proxy.Type.HTTP, socketAddress);
        URL url = new URL("http://google.com");
        URLConnection connection = url.openConnection(proxy);


        FileNameMap fileNameMap = connection.getFileNameMap();
        System.out.println("Content Type " +
                fileNameMap.getContentTypeFor("index.jsp"));

    }
}

Output
Content Type null

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US