Created
April 19, 2015 15:03
-
-
Save marius92mc/0c01f0ec397a19617cf5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String documentType(String file) | |
{ | |
String fileType = "Undetermined"; | |
try | |
{ | |
final URL url = new URL("file://" + file); | |
final URLConnection connection = url.openConnection(); | |
fileType = connection.getContentType(); | |
} | |
catch (MalformedURLException badUrlEx) | |
{ | |
System.out.println("ERROR: Bad URL - " + badUrlEx); | |
} | |
catch (IOException ioEx) | |
{ | |
System.out.println("Cannot access URLConnection - " + ioEx); | |
} | |
return fileType; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment