FileDocCategorySizeDatePackage
MidiFileWriter.javaAPI DocJava SE 5 API4034Fri Aug 26 14:57:50 BST 2005javax.sound.midi.spi

MidiFileWriter

public abstract class MidiFileWriter extends Object
A MidiFileWriter supplies MIDI file-writing services. Classes that implement this interface can write one or more types of MIDI file from a {@link Sequence} object.
author
Kara Kytle
version
1.17, 03/12/19
since
1.3

Fields Summary
Constructors Summary
Methods Summary
public abstract int[]getMidiFileTypes()
Obtains the set of MIDI file types for which file writing support is provided by this file writer.

return
array of file types. If no file types are supported, an array of length 0 is returned.

public abstract int[]getMidiFileTypes(javax.sound.midi.Sequence sequence)
Obtains the file types that this file writer can write from the sequence specified.

param
sequence the sequence for which MIDI file type support is queried
return
array of file types. If no file types are supported, returns an array of length 0.

public booleanisFileTypeSupported(int fileType)
Indicates whether file writing support for the specified MIDI file type is provided by this file writer.

param
fileType the file type for which write capabilities are queried
return
true if the file type is supported, otherwise false


	int types[] = getMidiFileTypes();
	for(int i=0; i<types.length; i++) {
	    if( fileType == types[i] ) {
		return true;
	    }
	}
	return false;
    
public booleanisFileTypeSupported(int fileType, javax.sound.midi.Sequence sequence)
Indicates whether a MIDI file of the file type specified can be written from the sequence indicated.

param
fileType the file type for which write capabilities are queried
param
sequence the sequence for which file writing support is queried
return
true if the file type is supported for this sequence, otherwise false


	int types[] = getMidiFileTypes( sequence );
	for(int i=0; i<types.length; i++) {
	    if( fileType == types[i] ) {
		return true;
	    }
	}
	return false;
    
public abstract intwrite(javax.sound.midi.Sequence in, int fileType, java.io.OutputStream out)
Writes a stream of bytes representing a MIDI file of the file type indicated to the output stream provided.

param
in sequence containing MIDI data to be written to the file
param
fileType type of the file to be written to the output stream
param
out stream to which the file data should be written
return
the number of bytes written to the output stream
throws
IOException if an I/O exception occurs
throws
IllegalArgumentException if the file type is not supported by this file writer
see
#isFileTypeSupported(int, Sequence)
see
#getMidiFileTypes(Sequence)

public abstract intwrite(javax.sound.midi.Sequence in, int fileType, java.io.File out)
Writes a stream of bytes representing a MIDI file of the file type indicated to the external file provided.

param
in sequence containing MIDI data to be written to the external file
param
fileType type of the file to be written to the external file
param
out external file to which the file data should be written
return
the number of bytes written to the file
throws
IOException if an I/O exception occurs
throws
IllegalArgumentException if the file type is not supported by this file writer
see
#isFileTypeSupported(int, Sequence)
see
#getMidiFileTypes(Sequence)