< prev index next >
test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2010, 2015, 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.
--- 1,7 ----
/*
! * Copyright (c) 2010, 2016, 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.
*** 28,37 ****
--- 28,39 ----
*/
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
+ import java.nio.file.Files;
+ import java.nio.file.Paths;
import javax.sound.sampled.*;
import com.sun.media.sound.*;
*** 97,116 ****
ByteArrayOutputStream baos = new ByteArrayOutputStream();
AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos);
buffer_wave = new ModelByteBuffer(baos.toByteArray());
test_file = File.createTempFile("test", ".raw");
! FileOutputStream fos = new FileOutputStream(test_file);
fos.write(baos.toByteArray());
! fos.close();
buffer_wave_ondisk = new ModelByteBuffer(test_file);
}
static void tearDown() throws Exception {
! if (!test_file.delete())
! test_file.deleteOnExit();
}
public static void testOpenStream(ModelByteBufferWavetable wavetable)
throws Exception {
AudioFloatInputStream ais = wavetable.openStream();
--- 99,117 ----
ByteArrayOutputStream baos = new ByteArrayOutputStream();
AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos);
buffer_wave = new ModelByteBuffer(baos.toByteArray());
test_file = File.createTempFile("test", ".raw");
! try (FileOutputStream fos = new FileOutputStream(test_file)) {
fos.write(baos.toByteArray());
! }
buffer_wave_ondisk = new ModelByteBuffer(test_file);
}
static void tearDown() throws Exception {
! Files.delete(Paths.get(test_file.getAbsolutePath()));
}
public static void testOpenStream(ModelByteBufferWavetable wavetable)
throws Exception {
AudioFloatInputStream ais = wavetable.openStream();
< prev index next >