List providers = getMidiFileWriters();
//$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
int bytesWritten = -2;
for (int i = 0; i < providers.size(); i++ ) {
MidiFileWriter writer = (MidiFileWriter) providers.get(i);
if( writer.isFileTypeSupported( fileType, in ) ) {
bytesWritten = writer.write(in, fileType, out);
break;
}
}
if (bytesWritten == -2) {
throw new IllegalArgumentException("MIDI file type is not supported");