jdk/test/javax/sound/midi/Gervill/RiffReaderWriter/GetFilePointer.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 GetFilePointer {
    37 public class GetFilePointer {
    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     {
    58             long p = readchunk.getFilePointer();
    59             long p = readchunk.getFilePointer();
    59             readchunk.readByte();
    60             readchunk.readByte();
    60             assertEquals(p+1,readchunk.getFilePointer());
    61             assertEquals(p+1,readchunk.getFilePointer());
    61             fis.close();
    62             fis.close();
    62             reader = null;
    63             reader = null;
    63 
       
    64 
       
    65         }
    64         }
    66         finally
    65         finally
    67         {
    66         {
    68             if(writer != null)
    67             if(writer != null)
    69                 writer.close();
    68                 writer.close();
    70             if(reader != null)
    69             if(reader != null)
    71                 reader.close();
    70                 reader.close();
    72 
    71             Files.delete(Paths.get(tempfile.getAbsolutePath()));
    73             if(tempfile.exists())
       
    74                 if(!tempfile.delete())
       
    75                     tempfile.deleteOnExit();
       
    76         }
    72         }
    77     }
    73     }
    78 }
    74 }