title: Cannot Create Audio Stream from Input Stream
body: <p>I am trying to get a sound file (.wav) to play when a button is clicked. The calls are all made correctly. When I click the button, an IOException is printed. This is the code for the method that starts the music:</p>
  
  <pre><code>public void playSound(String path) {
  
  //M:\Programming\workspace\testing\music.wav  &lt;--- String path
      InputStream in;
      AudioStream as = null;
  
      try {
          in = new FileInputStream(path);
          as = new AudioStream(in);
      } catch (FileNotFoundException e) {
          System.out.println("Audio file not found.");
          e.printStackTrace();
      } catch (IOException e) {
          System.out.println("Incorrect input.");
          e.printStackTrace();
      }
      AudioPlayer.player.start(as);
  }
  </code></pre>
  
  <p>This is the error:</p>
  
  <pre><code>java.io.IOException: could not create audio stream from input stream
  at sun.audio.AudioStream.&lt;init&gt;(Unknown Source)
  at GameWindow.playSound(GameWindow.java:484)
  at GameWindow$13.mouseReleased(GameWindow.java:385)
  at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
  at java.awt.Component.processMouseEvent(Unknown Source)
  at javax.swing.JComponent.processMouseEvent(Unknown Source)
  at java.awt.Component.processEvent(Unknown Source)
  at java.awt.Container.processEvent(Unknown Source)
  at java.awt.Component.dispatchEventImpl(Unknown Source)
  at java.awt.Container.dispatchEventImpl(Unknown Source)
  at java.awt.Component.dispatchEvent(Unknown Source)
  at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
  at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
  at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
  at java.awt.Container.dispatchEventImpl(Unknown Source)
  at java.awt.Window.dispatchEventImpl(Unknown Source)
  at java.awt.Component.dispatchEvent(Unknown Source)
  at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
  at java.awt.EventQueue.access$200(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.awt.EventQueue$4.run(Unknown Source)
  at java.awt.EventQueue$4.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
  at java.awt.EventQueue.dispatchEvent(Unknown Source)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.run(Unknown Source)
  </code></pre>
  
  <p>I have tried numerous methods to play audio files that I've found on Google, but all return this same error. What do I need to do to fix this? And if there is a better way to work with audio files, can you provide any resources to look at?</p>