Java String Suffix suffix(String mime)

Here you can find the source of suffix(String mime)

Description

Suggests a file name suffix for the given content type.

License

Open Source License

Parameter

Parameter Description
mime content type to find a suffix for

Return

suggested suffix, or "bin" if there is no known suffix

Declaration

public static String suffix(String mime) 

Method Source Code

//package com.java2s;
/*//  w ww  . java2 s.com
 * Shredzone Commons
 *
 * Copyright (C) 2012 Richard "Shred" K?rber
 *   http://commons.shredzone.org
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Suggests a file name suffix for the given content type.
     * <p>
     * The current implementation only detects the standard HTML image types.
     *
     * @param mime
     *            content type to find a suffix for
     * @return suggested suffix, or "bin" if there is no known suffix
     */
    public static String suffix(String mime) {
        // TODO: more suffixes
        switch (mime) {
        case "image/png":
            return "png";
        case "image/jpeg":
            return "jpg";
        case "image/gif":
            return "gif";
        default:
            return "bin";
        }
    }
}

Related

  1. suffix(final String source, final String target)
  2. suffix(String fname)
  3. suffix(String input, char delimiter)
  4. suffix(String name, char separator)
  5. suffix(String name, String suffix)
  6. suffix(String prefix, String path)
  7. suffix(String s, int delim)