< prev index next >

test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -92,11 +92,11 @@
                 }
             }
         }
     }
 
-    public static void main(final String[] args) {
+    public static void main(final String[] args) throws IOException {
         for (final FormatConversionProvider fcp : load(
                 FormatConversionProvider.class)) {
             System.out.println("fcp = " + fcp);
             for (final AudioFormat from : formats) {
                 for (final AudioFormat to : formats) {

@@ -137,39 +137,41 @@
      * Verifies the frame length after the stream was saved/read to/from
      * stream.
      */
     private static void testAfterSaveToStream(final AudioFileWriter afw,
                                               final AudioFileFormat.Type type,
-                                              final AudioInputStream ais) {
+                                              final AudioInputStream ais)
+            throws IOException {
         try {
             final ByteArrayOutputStream out = new ByteArrayOutputStream();
             afw.write(ais, type, out);
             final InputStream input = new ByteArrayInputStream(
                     out.toByteArray());
             validate(AudioSystem.getAudioInputStream(input).getFrameLength());
         } catch (IllegalArgumentException | UnsupportedAudioFileException
-                | IOException ignored) {
+                ignored) {
         }
     }
 
     /**
      * Verifies the frame length after the stream was saved/read to/from file.
      */
     private static void testAfterSaveToFile(final AudioFileWriter afw,
                                             final AudioFileFormat.Type type,
-                                            AudioInputStream ais) {
-        try {
+                                            AudioInputStream ais)
+            throws IOException {
             final File temp = File.createTempFile("sound", ".tmp");
-            temp.deleteOnExit();
+        try {
             afw.write(ais, type, temp);
             ais = AudioSystem.getAudioInputStream(temp);
             final long frameLength = ais.getFrameLength();
             ais.close();
-            Files.delete(Paths.get(temp.getAbsolutePath()));
             validate(frameLength);
         } catch (IllegalArgumentException | UnsupportedAudioFileException
-                | IOException ignored) {
+                ignored) {
+        } finally {
+            Files.delete(Paths.get(temp.getAbsolutePath()));
         }
     }
 
     /**
      * Verifies the frame length after the stream was converted to other
< prev index next >