is Audio File - Java File Path IO

Java examples for File Path IO:File Name

Description

is Audio File

Demo Code


//package com.java2s;

public class Main {
    public static boolean isAudioFile(String filename) {
        if (!(filename.length() > 3)) {
            return false;
        }/*  ww  w  .  ja  va 2  s  .co m*/

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

        ending = filename.substring(i - 4, i);

        if (ending.equalsIgnoreCase(".mp3"))
            return true;

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

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

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

        if (ending.equalsIgnoreCase(".mid"))
            return true;

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

        return false;
    }
}

Related Tutorials