title: Java UnsupportedAudioFileException when creating WAVE file from SourceDataLine
body: <p>I am sorry about my English.</p>
  <p>I am trying to create a program that records my speaker audio and saves it to a file.
  to create a WAVE file from my SourceDataLine I followed the steps in this question
  [https://stackoverflow.com/questions/9573920/how-can-i-write-the-contents-of-a-sourcedataline-to-a-file]</p>
  <p>and made the following code</p>
  <pre><code>Mixer speaker = AudioSystem.getMixer( availableMixers [3] );
      AudioFormat  audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100, 16, 2, 4, 44100 , false); 
      DataLine.Info  lineInfo  = new DataLine.Info (SourceDataLine.class , audioFormat);      
      SourceDataLine sourceDataLine = (SourceDataLine) speaker.getLine(lineInfo);
      
      sourceDataLine.open(audioFormat);
      sourceDataLine.start();
      
      byte [] data = new byte [sourceDataLine.getBufferSize() ]; // i am not sure what i should put here
      ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(data);
      
      File audioFile = new File(&quot;C:\\Users\\user\\Desktop\\RecordAudio\\record.wav&quot;);
      AudioSystem.write(AudioSystem.getAudioInputStream(byteArrayInputStream), AudioFileFormat.Type.WAVE, audioFile);
      
  </code></pre>
  <p>the output of the code is :</p>
  <p>javax.sound.sampled.UnsupportedAudioFileException: Stream of unsupported format
  at java.desktop/javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1014)
  at Main.main(Main.java:34)</p>
  <pre><code> and I am not sure why can you tell me what am I doing wrong?
  </code></pre>