0

What URL.setFileNameMap(FileNameMap map) method does, how to use it correctly and what is it used for? Is it any useful at all?

Docs are not very much of an explanation:

public static void setFileNameMap(FileNameMap map)

Sets the FileNameMap

+

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.

What is a mimetable and FileMap?

P.S. I read the docs for interface FileNameMap. It is also very brief and gives me no clue:

A simple interface which provides a mechanism to map between a file name and a MIME type string.

String getContentTypeFor(String fileName)

Gets the MIME type for the specified file name. Returns: a String indicating the MIME type for the specified file name.

P.S. There is a question about FileNameMap here, but it was not accepted and does not answer my question.

Code Complete
  • 3,146
  • 1
  • 15
  • 38

1 Answers1

0

This FileNameMap is internally used by method URLConnection.guessContentTypeFromName(String).
It is implemented like this:

public static String guessContentTypeFromName(String fname) {
    return getFileNameMap().getContentTypeFor(fname);
}
Thomas Fritsch
  • 9,639
  • 33
  • 37
  • 49