Here you can find the source of guessMime(String path)
public static String guessMime(String path)
//package com.java2s; /*//from w w w . j a va 2 s.c o m * Copyright 2011, Institute of Cybernetics at Tallinn University of Technology * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * TODO: use something more official, e.g. URLConnection.guessContentTypeFromName * * Note that "audio/amr" does not work with the transcription server (2011-04-05) */ public static String guessMime(String path) { String ext = getExtension(path); if (".aac".equals(ext)) return "audio/aac"; if (".flac".equals(ext)) return "audio/flac"; if (".aiff".equals(ext)) return "audio/aiff"; if (".aif".equals(ext)) return "audio/aiff"; if (".mka".equals(ext)) return "audio/x-matroska"; if (".mkv".equals(ext)) return "video/x-matroska"; if (".ogg".equals(ext)) return "audio/ogg"; if (".mp2".equals(ext)) return "audio/mpeg"; if (".mp3".equals(ext)) return "audio/mpeg"; if (".mp4".equals(ext)) return "audio/mp4"; if (".amr".equals(ext)) return "audio/AMR"; if (".3gpp".equals(ext)) return "audio/3gpp"; return "audio/wav"; } private static String getExtension(String path) { int dot = path.lastIndexOf('.'); if (dot == -1) { return ""; } return path.substring(dot); } }