javax.sound.sampled.spi.AudioFileReader#getAudioInputStream ( )源码实例Demo

下面列出了javax.sound.sampled.spi.AudioFileReader#getAudioInputStream ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk1.8-source-analysis   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided input stream.  The stream must
 * point to valid audio file data.  The implementation of this method may
 * require multiple parsers to
 * examine the stream to determine whether they support it.  These parsers must
 * be able to mark the stream, read enough data to determine whether they
 * support the stream, and, if not, reset the stream's read pointer to its original
 * position.  If the input stream does not support these operation, this method may fail
 * with an <code>IOException</code>.
 * @param stream the input stream from which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data contained
 * in the input stream.
 * @throws UnsupportedAudioFileException if the stream does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static AudioInputStream getAudioInputStream(InputStream stream)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input stream");
    } else {
        return audioStream;
    }
}
 
源代码2 项目: jdk1.8-source-analysis   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the URL provided.  The URL must
 * point to valid audio file data.
 * @param url the URL for which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
 * to by the URL
 * @throws UnsupportedAudioFileException if the URL does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static AudioInputStream getAudioInputStream(URL url)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input URL");
    } else {
        return audioStream;
    }
}
 
源代码3 项目: jdk1.8-source-analysis   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided <code>File</code>.  The <code>File</code> must
 * point to valid audio file data.
 * @param file the <code>File</code> for which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
 * to by the <code>File</code>
 * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static AudioInputStream getAudioInputStream(File file)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input file");
    } else {
        return audioStream;
    }
}
 
源代码4 项目: dragonwell8_jdk   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided input stream.  The stream must
 * point to valid audio file data.  The implementation of this method may
 * require multiple parsers to
 * examine the stream to determine whether they support it.  These parsers must
 * be able to mark the stream, read enough data to determine whether they
 * support the stream, and, if not, reset the stream's read pointer to its original
 * position.  If the input stream does not support these operation, this method may fail
 * with an <code>IOException</code>.
 * @param stream the input stream from which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data contained
 * in the input stream.
 * @throws UnsupportedAudioFileException if the stream does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static AudioInputStream getAudioInputStream(InputStream stream)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input stream");
    } else {
        return audioStream;
    }
}
 
源代码5 项目: dragonwell8_jdk   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided <code>File</code>.  The <code>File</code> must
 * point to valid audio file data.
 * @param file the <code>File</code> for which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
 * to by the <code>File</code>
 * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static AudioInputStream getAudioInputStream(File file)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input file");
    } else {
        return audioStream;
    }
}
 
源代码6 项目: TencentKona-8   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the URL provided.  The URL must
 * point to valid audio file data.
 * @param url the URL for which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
 * to by the URL
 * @throws UnsupportedAudioFileException if the URL does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static AudioInputStream getAudioInputStream(URL url)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input URL");
    } else {
        return audioStream;
    }
}
 
源代码7 项目: jdk8u60   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided input stream.  The stream must
 * point to valid audio file data.  The implementation of this method may
 * require multiple parsers to
 * examine the stream to determine whether they support it.  These parsers must
 * be able to mark the stream, read enough data to determine whether they
 * support the stream, and, if not, reset the stream's read pointer to its original
 * position.  If the input stream does not support these operation, this method may fail
 * with an <code>IOException</code>.
 * @param stream the input stream from which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data contained
 * in the input stream.
 * @throws UnsupportedAudioFileException if the stream does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static AudioInputStream getAudioInputStream(InputStream stream)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input stream");
    } else {
        return audioStream;
    }
}
 
源代码8 项目: openjdk-jdk8u-backup   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided <code>File</code>.  The <code>File</code> must
 * point to valid audio file data.
 * @param file the <code>File</code> for which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
 * to by the <code>File</code>
 * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static AudioInputStream getAudioInputStream(File file)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input file");
    } else {
        return audioStream;
    }
}
 
源代码9 项目: JDKSourceCode1.8   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided input stream.  The stream must
 * point to valid audio file data.  The implementation of this method may
 * require multiple parsers to
 * examine the stream to determine whether they support it.  These parsers must
 * be able to mark the stream, read enough data to determine whether they
 * support the stream, and, if not, reset the stream's read pointer to its original
 * position.  If the input stream does not support these operation, this method may fail
 * with an <code>IOException</code>.
 * @param stream the input stream from which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data contained
 * in the input stream.
 * @throws UnsupportedAudioFileException if the stream does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static AudioInputStream getAudioInputStream(InputStream stream)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input stream");
    } else {
        return audioStream;
    }
}
 
源代码10 项目: jdk8u-jdk   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided input stream.  The stream must
 * point to valid audio file data.  The implementation of this method may
 * require multiple parsers to
 * examine the stream to determine whether they support it.  These parsers must
 * be able to mark the stream, read enough data to determine whether they
 * support the stream, and, if not, reset the stream's read pointer to its original
 * position.  If the input stream does not support these operation, this method may fail
 * with an <code>IOException</code>.
 * @param stream the input stream from which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data contained
 * in the input stream.
 * @throws UnsupportedAudioFileException if the stream does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static AudioInputStream getAudioInputStream(InputStream stream)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input stream");
    } else {
        return audioStream;
    }
}
 
源代码11 项目: JDKSourceCode1.8   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided <code>File</code>.  The <code>File</code> must
 * point to valid audio file data.
 * @param file the <code>File</code> for which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
 * to by the <code>File</code>
 * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static AudioInputStream getAudioInputStream(File file)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input file");
    } else {
        return audioStream;
    }
}
 
源代码12 项目: openjdk-jdk8u   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided input stream.  The stream must
 * point to valid audio file data.  The implementation of this method may
 * require multiple parsers to
 * examine the stream to determine whether they support it.  These parsers must
 * be able to mark the stream, read enough data to determine whether they
 * support the stream, and, if not, reset the stream's read pointer to its original
 * position.  If the input stream does not support these operation, this method may fail
 * with an <code>IOException</code>.
 * @param stream the input stream from which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data contained
 * in the input stream.
 * @throws UnsupportedAudioFileException if the stream does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static AudioInputStream getAudioInputStream(InputStream stream)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input stream");
    } else {
        return audioStream;
    }
}
 
源代码13 项目: openjdk-jdk8u   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the URL provided.  The URL must
 * point to valid audio file data.
 * @param url the URL for which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
 * to by the URL
 * @throws UnsupportedAudioFileException if the URL does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static AudioInputStream getAudioInputStream(URL url)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input URL");
    } else {
        return audioStream;
    }
}
 
源代码14 项目: openjdk-jdk8u   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided <code>File</code>.  The <code>File</code> must
 * point to valid audio file data.
 * @param file the <code>File</code> for which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
 * to by the <code>File</code>
 * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static AudioInputStream getAudioInputStream(File file)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input file");
    } else {
        return audioStream;
    }
}
 
源代码15 项目: openjdk-jdk8u-backup   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided input stream.  The stream must
 * point to valid audio file data.  The implementation of this method may
 * require multiple parsers to
 * examine the stream to determine whether they support it.  These parsers must
 * be able to mark the stream, read enough data to determine whether they
 * support the stream, and, if not, reset the stream's read pointer to its original
 * position.  If the input stream does not support these operation, this method may fail
 * with an <code>IOException</code>.
 * @param stream the input stream from which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data contained
 * in the input stream.
 * @throws UnsupportedAudioFileException if the stream does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static AudioInputStream getAudioInputStream(InputStream stream)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input stream");
    } else {
        return audioStream;
    }
}
 
源代码16 项目: jdk8u-jdk   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided <code>File</code>.  The <code>File</code> must
 * point to valid audio file data.
 * @param file the <code>File</code> for which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
 * to by the <code>File</code>
 * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static AudioInputStream getAudioInputStream(File file)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

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

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input file");
    } else {
        return audioStream;
    }
}
 
源代码17 项目: Bytecoder   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided {@code File}. The
 * {@code File} must point to valid audio file data.
 *
 * @param  file the {@code File} for which the {@code AudioInputStream}
 *         should be constructed
 * @return an {@code AudioInputStream} object based on the audio file data
 *         pointed to by the {@code File}
 * @throws UnsupportedAudioFileException if the {@code File} does not point
 *         to valid audio file data recognized by the system
 * @throws IOException if an I/O exception occurs
 * @throws NullPointerException if {@code file} is {@code null}
 */
public static AudioInputStream getAudioInputStream(final File file)
        throws UnsupportedAudioFileException, IOException {
    Objects.requireNonNull(file);

    for (final AudioFileReader reader : getAudioFileReaders()) {
        try {
            return reader.getAudioInputStream(file);
        } catch (final UnsupportedAudioFileException ignored) {
        }
    }
    throw new UnsupportedAudioFileException("File of unsupported format");
}
 
源代码18 项目: Bytecoder   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided input stream. The stream
 * must point to valid audio file data. The implementation of this method
 * may require multiple parsers to examine the stream to determine whether
 * they support it. These parsers must be able to mark the stream, read
 * enough data to determine whether they support the stream, and reset the
 * stream's read pointer to its original position. If the input stream does
 * not support these operation, this method may fail with an
 * {@code IOException}.
 *
 * @param  stream the input stream from which the {@code AudioInputStream}
 *         should be constructed
 * @return an {@code AudioInputStream} object based on the audio file data
 *         contained in the input stream
 * @throws UnsupportedAudioFileException if the stream does not point to
 *         valid audio file data recognized by the system
 * @throws IOException if an I/O exception occurs
 * @throws NullPointerException if {@code stream} is {@code null}
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static AudioInputStream getAudioInputStream(final InputStream stream)
        throws UnsupportedAudioFileException, IOException {
    Objects.requireNonNull(stream);

    for (final AudioFileReader reader : getAudioFileReaders()) {
        try {
            return reader.getAudioInputStream(stream);
        } catch (final UnsupportedAudioFileException ignored) {
        }
    }
    throw new UnsupportedAudioFileException("Stream of unsupported format");
}
 
源代码19 项目: openjdk-jdk9   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided input stream. The stream
 * must point to valid audio file data. The implementation of this method
 * may require multiple parsers to examine the stream to determine whether
 * they support it. These parsers must be able to mark the stream, read
 * enough data to determine whether they support the stream, and reset the
 * stream's read pointer to its original position. If the input stream does
 * not support these operation, this method may fail with an
 * {@code IOException}.
 *
 * @param  stream the input stream from which the {@code AudioInputStream}
 *         should be constructed
 * @return an {@code AudioInputStream} object based on the audio file data
 *         contained in the input stream
 * @throws UnsupportedAudioFileException if the stream does not point to
 *         valid audio file data recognized by the system
 * @throws IOException if an I/O exception occurs
 * @throws NullPointerException if {@code stream} is {@code null}
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static AudioInputStream getAudioInputStream(final InputStream stream)
        throws UnsupportedAudioFileException, IOException {
    Objects.requireNonNull(stream);

    for (final AudioFileReader reader : getAudioFileReaders()) {
        try {
            return reader.getAudioInputStream(stream);
        } catch (final UnsupportedAudioFileException ignored) {
        }
    }
    throw new UnsupportedAudioFileException("Stream of unsupported format");
}
 
源代码20 项目: openjdk-jdk9   文件: AudioSystem.java
/**
 * Obtains an audio input stream from the provided {@code File}. The
 * {@code File} must point to valid audio file data.
 *
 * @param  file the {@code File} for which the {@code AudioInputStream}
 *         should be constructed
 * @return an {@code AudioInputStream} object based on the audio file data
 *         pointed to by the {@code File}
 * @throws UnsupportedAudioFileException if the {@code File} does not point
 *         to valid audio file data recognized by the system
 * @throws IOException if an I/O exception occurs
 * @throws NullPointerException if {@code file} is {@code null}
 */
public static AudioInputStream getAudioInputStream(final File file)
        throws UnsupportedAudioFileException, IOException {
    Objects.requireNonNull(file);

    for (final AudioFileReader reader : getAudioFileReaders()) {
        try {
            return reader.getAudioInputStream(file);
        } catch (final UnsupportedAudioFileException ignored) {
        }
    }
    throw new UnsupportedAudioFileException("File of unsupported format");
}