title: How to convert a byte array into an AudioInputStream in Java
body: <p>I want to convert a byte array into an AudioInputStream. The byte array was filled from a *.wav file before. I have the following code:</p>
  
  <pre><code>    public static AudioInputStream writeBytesBackToStream(byte[] bytes) {
      ByteArrayInputStream baiut = new ByteArrayInputStream(bytes);
      AudioInputStream stream = null;
      try {
          stream = AudioSystem.getAudioInputStream(baiut);
      } catch (UnsupportedAudioFileException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      if(stream.equals(null) || stream == null) {
          System.out.println("WARNING: Stream read by byte array is null!");
      }
      return stream;
  }
  </code></pre>
  
  <p>Now I only want to convert this byte array into an AudioInputStream, but an UnsupportedAudioFileException is thrown:</p>
  
  <pre><code>javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from    input stream
  </code></pre>
  
  <p>Has anyone got an idea?</p>