MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / guessMimeType

Method guessMimeType

CodenameOne/src/com/codename1/io/Util.java:2698–2711  ·  view source on GitHub ↗
(String sourceFile)

Source from the content-addressed store, hash-verified

2696 ///
2697 /// - `IOException`
2698 public static String guessMimeType(String sourceFile) throws IOException {
2699 InputStream inputStream = null; //NOPMD CloseResource
2700 try {
2701 if (sourceFile.indexOf('/') > -1) {
2702 inputStream = FileSystemStorage.getInstance().openInputStream(sourceFile);
2703 } else {
2704 // Storage is a flat file system
2705 inputStream = Storage.getInstance().createInputStream(sourceFile);
2706 }
2707 return guessMimeType(inputStream);
2708 } finally {
2709 Util.cleanup(inputStream);
2710 }
2711 }
2712
2713 /// Tries to determine the mime type of an InputStream based on its first
2714 /// bytes.Direct inspection of the bytes to determine the content type is

Callers 3

isJPEGMethod · 0.95
isPNGMethod · 0.95
invokeStatic16Method · 0.80

Calls 10

getInstanceMethod · 0.95
getInstanceMethod · 0.95
cleanupMethod · 0.95
copyOfMethod · 0.95
arraycopyMethod · 0.95
minMethod · 0.95
createInputStreamMethod · 0.80
indexOfMethod · 0.65
openInputStreamMethod · 0.65
readMethod · 0.65

Tested by

no test coverage detected