AudioSystem.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:jdk8u_jdk 作者:
/**
 * Obtains the audio file format of the specified URL.  The URL must
 * point to valid audio file data.
 * @param url the URL from which file format information should be
 * extracted
 * @return an <code>AudioFileFormat</code> object describing the audio file format
 * @throws UnsupportedAudioFileException if the URL does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an input/output exception occurs
 */
public static AudioFileFormat getAudioFileFormat(URL url)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioFileFormat format = null;

    for(int i = 0; i < providers.size(); i++ ) {
        AudioFileReader reader = (AudioFileReader) providers.get(i);
        try {
            format = reader.getAudioFileFormat( url ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new UnsupportedAudioFileException("file is not a supported file type");
    } else {
        return format;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号