Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Can someone help me fix this error in Java?
// The "TestSound" class.
import java.awt.*;
import hsa.Console;
import sun.audio.*;
import java.io.*;
public class TestSound
{
static Console c; // The output console
public static void main (String[] args)
{
c = new Console ();
AudioPlayer BGP = AudioPlayer.player;
AudioStream BGM;
AudioData MD;
ContinuousAudioDataStream loop = null;
try
{
BGM = new AudioStream (new FileInputStream ("Deal.wav"));
MD = BGM.getData ();
loop = new ContinuousAudioDataStream (MD);
}
catch (IOException error)
{
c.print ("error");
}
BGP.start (loop);
} // main method
} // TestSound class
-------------------------------
I am using Ready To Program With Java (with HSA consoles). The program runs but when it trys to play the audio file the "catch" section is executed which obviously means something isn't right. Any advice?
1 Answer
- 7 years agoFavorite Answer
Most probably the program can't find Deal.wav , make sure you have the correct file path and in your catch instead of c.print ("error") change it to System.out.println(error.getMessage());
catch (IOException error)
{
c.print ("error");
}