Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;

import java.util.Locale;

public class Main {
    public static boolean isSupportedAudioFormat(File file) {
        return isMP3File(file) || isOGGFile(file) || isM4AFile(file);
    }

    public static boolean isSupportedAudioFormat(String file) {
        return isMP3File(file) || isOGGFile(file) || isM4AFile(file);
    }

    public static boolean isMP3File(String in) {
        boolean retVal = false;

        in = in.toLowerCase(Locale.US);
        if (in.endsWith(".mp3"))
            retVal = true;

        return retVal;
    }

    public static boolean isMP3File(File in) {
        boolean retVal = isMP3File(in.getName());
        return retVal;
    }

    public static boolean isOGGFile(String in) {
        boolean retVal = false;

        in = in.toLowerCase(Locale.US);
        if (in.endsWith(".ogg"))
            retVal = true;

        return retVal;
    }

    public static boolean isOGGFile(File in) {
        boolean retVal = isOGGFile(in.getName());
        return retVal;
    }

    public static boolean isM4AFile(String in) {
        boolean retVal = false;

        in = in.toLowerCase(Locale.US);
        if (in.endsWith(".m4a") || in.endsWith(".m4p"))
            retVal = true;

        return retVal;
    }

    public static boolean isM4AFile(File in) {
        boolean retVal = isM4AFile(in.getName());
        return retVal;
    }
}