title: Java's sound API doesn't work with all .WAV files?
body: <p>I am currently having trouble playing around with the <code>javax.sound.sampled</code> library. Here's the <a href="https://stackoverflow.com/help/mcve">MCV</a> code that I use to play my audio files:</p>
  
  <pre><code>import javax.sound.sampled.*;
  import java.io.File;
  
  public class Foo
  {
      public static void main(String[] args)
      {
          try
          {
              File f = new File("alarm.wav");
              AudioInputStream ais = AudioSystem.getAudioInputStream(f);
              Clip clip = AudioSystem.getClip();
  
              clip.open(ais);
              clip.start();
          }
          catch (Exception e)
          {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>This code will sometimes throw an <code>UnsupportedAudioFileException</code>. </p>
  
  <p><strong>Basically, I have 5 .WAV files that I know are uncorrupted because they play perfectly fine when I open them in my music playing software. However, the Java program only works with 3 of them.</strong></p>
  
  <p><a href="http://docs.oracle.com/javase/8/docs/technotes/guides/sound/" rel="nofollow noreferrer">Oracle mentions support for this file format here.</a> How can I make sure that all of my .WAV files are compatible with Java's audio API? Is there a foolproof way of playing .WAV files if for some reason they do not have the appropriate encoding?</p>