Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {

    public static boolean isVideo(String filename) {
        String mimeType = getMimeType(filename);
        if (mimeType != null && mimeType.startsWith("video/")) {
            return true;
        } else {
            return false;
        }
    }

    public static String getMimeType(String filename) {
        String mimeType = null;

        if (filename == null) {
            return mimeType;
        }
        if (filename.endsWith(".3gp")) {
            mimeType = "video/3gpp";
        } else if (filename.endsWith(".mid")) {
            mimeType = "audio/mid";
        } else if (filename.endsWith(".mp3")) {
            mimeType = "audio/mpeg";
        } else if (filename.endsWith(".xml")) {
            mimeType = "text/xml";
        } else {
            mimeType = "";
        }
        return mimeType;
    }
}