0

I am parsing a MIDI file in Java. At first I create a sequence using:

Sequence sequence = MidiSystem.getSequence(paFile);

which throws checked IOException. Am I supposed to close this resource somehow? If so, why doesn't sequence or MidiSystem implement closeable?

Leprechaun
  • 852
  • 6
  • 25

1 Answers1

0

As per http://docs.oracle.com/javase/7/docs/api/javax/sound/midi/MidiSystem.html#getSequence%28java.io.File%29, MidiSystem.getSequence(File) throws InvalidMidiDataException and IOException. The first is pretty self-explanatory; it's accounting for the possibility that you're trying to read something that's not properly a midi file. The second is a derived consequence of using File; there are all kinds of straightforward errors that could come from that. (Not reading a valid file; bad sector on a disk, etc.) So no, I don't think you have to close the resource, but you do have to decide what to do w/r/t those possible exceptions.