jdk/test/javax/sound/midi/Gervill/RiffReaderWriter/ReadUnsignedByte.java
changeset 45341 b7cc7f639ecf
parent 31448 1066345d2a8a
equal deleted inserted replaced
45023:323c0edaa17b 45341:b7cc7f639ecf
     1 /*
     1 /*
     2  * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    26    @modules java.desktop/com.sun.media.sound
    26    @modules java.desktop/com.sun.media.sound
    27 */
    27 */
    28 
    28 
    29 import java.io.File;
    29 import java.io.File;
    30 import java.io.FileInputStream;
    30 import java.io.FileInputStream;
       
    31 import java.nio.file.Files;
       
    32 import java.nio.file.Paths;
    31 
    33 
    32 import javax.sound.sampled.*;
    34 import com.sun.media.sound.RIFFReader;
    33 
    35 import com.sun.media.sound.RIFFWriter;
    34 import com.sun.media.sound.*;
       
    35 
    36 
    36 public class ReadUnsignedByte {
    37 public class ReadUnsignedByte {
    37 
    38 
    38     private static void assertEquals(Object a, Object b) throws Exception
    39     private static void assertEquals(Object a, Object b) throws Exception
    39     {
    40     {
    59             RIFFReader readchunk = reader.nextChunk();
    60             RIFFReader readchunk = reader.nextChunk();
    60             assertEquals(readchunk.getFormat(), "TSCH");
    61             assertEquals(readchunk.getFormat(), "TSCH");
    61             assertEquals(reader.readUnsignedByte(), 77);
    62             assertEquals(reader.readUnsignedByte(), 77);
    62             fis.close();
    63             fis.close();
    63             reader = null;
    64             reader = null;
    64 
       
    65 
       
    66         }
    65         }
    67         finally
    66         finally
    68         {
    67         {
    69             if(writer != null)
    68             if(writer != null)
    70                 writer.close();
    69                 writer.close();
    71             if(reader != null)
    70             if(reader != null)
    72                 reader.close();
    71                 reader.close();
    73 
    72             Files.delete(Paths.get(tempfile.getAbsolutePath()));
    74             if(tempfile.exists())
       
    75                 if(!tempfile.delete())
       
    76                     tempfile.deleteOnExit();
       
    77         }
    73         }
    78     }
    74     }
    79 }
    75 }