int bytesRead = 0;
long bytesWritten = 0;
if( !isFileTypeSupported(type,in) ) {
throw new IllegalArgumentException("Could not write MIDI file");
}
// First get the fileStream from this sequence
InputStream fileStream = getFileStream(type,in);
if (fileStream == null) {
throw new IllegalArgumentException("Could not write MIDI file");
}
buffer = new byte[bufferSize];
while( (bytesRead = fileStream.read( buffer )) >= 0 ) {
out.write( buffer, 0, (int)bytesRead );