Java tutorial
//package com.java2s; import java.io.File; import java.util.Locale; public class Main { public static boolean isSupportedFormatForSchema(File file, String schemaURI) { if (isSupportedMultipleFormat(file)) return true; else if ("http://www.limewire.com/schemas/audio.xsd".equals(schemaURI)) return isSupportedAudioFormat(file); else if ("http://www.limewire.com/schemas/video.xsd".equals(schemaURI)) return isSupportedVideoFormat(file); else return false; } public static boolean isSupportedMultipleFormat(File file) { return isSupportedMultipleFormat(file.getName()); } public static boolean isSupportedMultipleFormat(String file) { return isASFFile(file); } public static boolean isSupportedAudioFormat(File file) { return isSupportedAudioFormat(file.getName()); } public static boolean isSupportedAudioFormat(String file) { return isMP3File(file) || isOGGFile(file) || isM4AFile(file) || isWMAFile(file) || isFLACFile(file); } public static boolean isSupportedVideoFormat(File file) { return isSupportedVideoFormat(file.getName()); } public static boolean isSupportedVideoFormat(String file) { return isRIFFFile(file) || isOGMFile(file) || isWMVFile(file); } public static boolean isASFFile(File f) { return isASFFile(f.getName()); } public static boolean isASFFile(String in) { in = in.toLowerCase(Locale.US); return in.endsWith(".asf") || in.endsWith(".wm"); } public static boolean isMP3File(File in) { return isMP3File(in.getName()); } public static boolean isMP3File(String in) { return in.toLowerCase(Locale.US).endsWith(".mp3"); } public static boolean isOGGFile(File in) { return isOGGFile(in.getName()); } public static boolean isOGGFile(String in) { return in.toLowerCase(Locale.US).endsWith(".ogg"); } public static boolean isM4AFile(File in) { return isM4AFile(in.getName()); } public static boolean isM4AFile(String in) { in = in.toLowerCase(Locale.US); return in.endsWith(".m4a") || in.endsWith(".m4p"); } public static boolean isWMAFile(File f) { return isWMAFile(f.getName()); } public static boolean isWMAFile(String in) { return in.toLowerCase(Locale.US).endsWith(".wma"); } public static boolean isFLACFile(File in) { return isFLACFile(in.getName()); } public static boolean isFLACFile(String in) { in = in.toLowerCase(Locale.US); return in.endsWith(".flac") || in.endsWith(".fla"); } public static boolean isRIFFFile(File f) { return isRIFFFile(f.getName()); } public static boolean isRIFFFile(String in) { return in.toLowerCase(Locale.US).endsWith(".avi"); } public static boolean isOGMFile(File f) { return isOGMFile(f.getName()); } public static boolean isOGMFile(String in) { return in.toLowerCase(Locale.US).endsWith(".ogm"); } public static boolean isWMVFile(File f) { return isWMVFile(f.getName()); } public static boolean isWMVFile(String in) { return in.toLowerCase(Locale.US).endsWith(".wmv"); } }