is Multimedia File - Java File Path IO

Java examples for File Path IO:File Name

Description

is Multimedia File

Demo Code


//package com.java2s;

public class Main {
    public static boolean isMultimediaFile(String filename) {
        if (!(filename.length() > 3)) {
            return false;
        }//from ww  w .j a  v  a2  s  .  co m

        int i = filename.length();
        String ending = filename.substring(i - 3, i);
        if (ending.equalsIgnoreCase(".--")) {
            return true;
        }

        ending = filename.substring(i - 4, i);
        if (ending.equalsIgnoreCase(".avi")) {
            return true;
        }

        if (ending.equalsIgnoreCase(".mpg")) {
            return true;
        }

        int index = i - 5;
        if (index >= 0) {
            ending = filename.substring(index, i);
            if (ending.equalsIgnoreCase(".mpeg")) {
                return true;
            }
        }

        return false;
    }
}

Related Tutorials