equal
deleted
inserted
replaced
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. |
27 */ |
27 */ |
28 |
28 |
29 import java.io.ByteArrayInputStream; |
29 import java.io.ByteArrayInputStream; |
30 import java.io.ByteArrayOutputStream; |
30 import java.io.ByteArrayOutputStream; |
31 import java.io.File; |
31 import java.io.File; |
|
32 import java.nio.file.Files; |
|
33 import java.nio.file.Paths; |
32 |
34 |
33 import javax.sound.sampled.*; |
35 import com.sun.media.sound.RIFFReader; |
34 |
36 import com.sun.media.sound.RIFFWriter; |
35 import com.sun.media.sound.*; |
|
36 |
37 |
37 public class WriteOutputStream { |
38 public class WriteOutputStream { |
38 |
39 |
39 private static void assertEquals(Object a, Object b) throws Exception |
40 private static void assertEquals(Object a, Object b) throws Exception |
40 { |
41 { |
61 RIFFReader readchunk = reader.nextChunk(); |
62 RIFFReader readchunk = reader.nextChunk(); |
62 assertEquals(readchunk.getFormat(), "TSCH"); |
63 assertEquals(readchunk.getFormat(), "TSCH"); |
63 assertEquals(readchunk.read(), 33); |
64 assertEquals(readchunk.read(), 33); |
64 fis.close(); |
65 fis.close(); |
65 reader = null; |
66 reader = null; |
66 |
|
67 |
|
68 } |
67 } |
69 finally |
68 finally |
70 { |
69 { |
71 if(writer != null) |
70 if(writer != null) |
72 writer.close(); |
71 writer.close(); |
73 if(reader != null) |
72 if(reader != null) |
74 reader.close(); |
73 reader.close(); |
75 |
74 Files.delete(Paths.get(tempfile.getAbsolutePath())); |
76 if(tempfile.exists()) |
|
77 if(!tempfile.delete()) |
|
78 tempfile.deleteOnExit(); |
|
79 } |
75 } |
80 } |
76 } |
81 } |
77 } |