Java Code Examples for javax.sound.midi.spi.MidiFileReader#getMidiFileFormat()

The following examples show how to use javax.sound.midi.spi.MidiFileReader#getMidiFileFormat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MidiSystem.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

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

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 2
Source File: MidiSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

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

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 3
Source File: MidiSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 4
Source File: MidiSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 5
Source File: MidiSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 6
Source File: MidiSystem.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

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

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 7
Source File: MidiSystem.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

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

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 8
Source File: MidiSystem.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified {@code File}. The
 * {@code File} must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader. It may fail with an
 * {@code InvalidMidiDataException} even for valid files if no compatible
 * file reader is installed. It will also fail with an
 * {@code InvalidMidiDataException} if a compatible file reader is
 * installed, but encounters errors while determining the file format.
 *
 * @param  file the {@code File} from which file format information should
 *         be extracted
 * @return a {@code MidiFileFormat} object describing the MIDI file format
 * @throws InvalidMidiDataException if the {@code File} does not point to
 *         valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 * @throws NullPointerException if {@code file} is {@code null}
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(final File file)
        throws InvalidMidiDataException, IOException {
    Objects.requireNonNull(file);

    List<MidiFileReader> providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 9
Source File: MidiSystem.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL. The URL
 * must point to valid MIDI file data for a file type recognized by the
 * system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader. It may fail with an
 * {@code InvalidMidiDataException} even for valid files if no compatible
 * file reader is installed. It will also fail with an
 * {@code InvalidMidiDataException} if a compatible file reader is
 * installed, but encounters errors while determining the file format.
 *
 * @param  url the URL from which file format information should be
 *         extracted
 * @return a {@code MidiFileFormat} object describing the MIDI file format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 *         file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 * @throws NullPointerException if {@code url} is {@code null}
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(final URL url)
        throws InvalidMidiDataException, IOException {
    Objects.requireNonNull(url);

    List<MidiFileReader> providers = getMidiFileReaders();
    MidiFileFormat format = null;

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

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 10
Source File: MidiSystem.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 11
Source File: MidiSystem.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

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

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 12
Source File: MidiSystem.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified {@code File}. The
 * {@code File} must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader. It may fail with an
 * {@code InvalidMidiDataException} even for valid files if no compatible
 * file reader is installed. It will also fail with an
 * {@code InvalidMidiDataException} if a compatible file reader is
 * installed, but encounters errors while determining the file format.
 *
 * @param  file the {@code File} from which file format information should
 *         be extracted
 * @return a {@code MidiFileFormat} object describing the MIDI file format
 * @throws InvalidMidiDataException if the {@code File} does not point to
 *         valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 * @throws NullPointerException if {@code file} is {@code null}
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(final File file)
        throws InvalidMidiDataException, IOException {
    Objects.requireNonNull(file);

    List<MidiFileReader> providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 13
Source File: MidiSystem.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

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

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 14
Source File: MidiSystem.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 15
Source File: MidiSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 16
Source File: MidiSystem.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

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

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 17
Source File: MidiSystem.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified input stream.
 * The stream must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This method and/or the code it invokes may need to read some data from
 * the stream to determine whether its data format is supported.  The
 * implementation may therefore
 * need to mark the stream, read enough data to determine whether it is in
 * a supported format, and reset the stream's read pointer to its original
 * position.  If the input stream does not permit this set of operations,
 * this method may fail with an <code>IOException</code>.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param stream the input stream from which file format information
 * should be extracted
 * @return an <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the stream does not point to valid
 * MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the
 * stream
 * @see #getMidiFileFormat(URL)
 * @see #getMidiFileFormat(File)
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static MidiFileFormat getMidiFileFormat(InputStream stream)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( stream ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("input stream is not a supported file type");
    } else {
        return format;
    }
}
 
Example 18
Source File: MidiSystem.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified input stream.
 * The stream must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This method and/or the code it invokes may need to read some data from
 * the stream to determine whether its data format is supported.  The
 * implementation may therefore
 * need to mark the stream, read enough data to determine whether it is in
 * a supported format, and reset the stream's read pointer to its original
 * position.  If the input stream does not permit this set of operations,
 * this method may fail with an <code>IOException</code>.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param stream the input stream from which file format information
 * should be extracted
 * @return an <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the stream does not point to valid
 * MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the
 * stream
 * @see #getMidiFileFormat(URL)
 * @see #getMidiFileFormat(File)
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static MidiFileFormat getMidiFileFormat(InputStream stream)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( stream ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("input stream is not a supported file type");
    } else {
        return format;
    }
}
 
Example 19
Source File: MidiSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified input stream.
 * The stream must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This method and/or the code it invokes may need to read some data from
 * the stream to determine whether its data format is supported.  The
 * implementation may therefore
 * need to mark the stream, read enough data to determine whether it is in
 * a supported format, and reset the stream's read pointer to its original
 * position.  If the input stream does not permit this set of operations,
 * this method may fail with an <code>IOException</code>.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param stream the input stream from which file format information
 * should be extracted
 * @return an <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the stream does not point to valid
 * MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the
 * stream
 * @see #getMidiFileFormat(URL)
 * @see #getMidiFileFormat(File)
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static MidiFileFormat getMidiFileFormat(InputStream stream)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( stream ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("input stream is not a supported file type");
    } else {
        return format;
    }
}
 
Example 20
Source File: MidiSystem.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified input stream.
 * The stream must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This method and/or the code it invokes may need to read some data from
 * the stream to determine whether its data format is supported.  The
 * implementation may therefore
 * need to mark the stream, read enough data to determine whether it is in
 * a supported format, and reset the stream's read pointer to its original
 * position.  If the input stream does not permit this set of operations,
 * this method may fail with an <code>IOException</code>.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param stream the input stream from which file format information
 * should be extracted
 * @return an <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the stream does not point to valid
 * MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the
 * stream
 * @see #getMidiFileFormat(URL)
 * @see #getMidiFileFormat(File)
 * @see InputStream#markSupported
 * @see InputStream#mark
 */
public static MidiFileFormat getMidiFileFormat(InputStream stream)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( stream ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("input stream is not a supported file type");
    } else {
        return format;
    }
}