class FlacAudioFileReader extends AudioFileReader {

    public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException {
        InputStream inputStream = new FileInputStream(file);
        try {
            return getAudioInputStream(inputStream, (int) file.length());
        } catch (UnsupportedAudioFileException e) {
            try {
                inputStream.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
            throw e;
        } catch (IOException e) {
            try {
                inputStream.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
            throw e;
        }
    }

}

class FlacAudioFileReaderTest {

    @Test
    public void testGetAudioInputStreamWithUnsupportedFile() throws IOException {

        final FlacAudioFileReader flacAudioFileReader = new FlacAudioFileReader();
        final File file = File.createTempFile("flacTest", ".wav");
        final OutputStream out = new FileOutputStream(file);
        out.write(new byte[2048]);
        out.close();
        try {
            flacAudioFileReader.getAudioInputStream(file);
            fail("Expected UnsupportedAudioFileException");
        } catch (UnsupportedAudioFileException e) {
            // expected this
        } finally {
            file.delete();
        }
    }

}