title: Converting Byte Array to Wav file
body: <p>After extensive research into the subject I have reached a brick wall.</p>
  
  <p>All I want to do is add a collection of .wav files into a byte array, one after another, and output them all into one complete newly created .wav file. I extract all the .wav data into a byte array, skipping the .wav header and going straight for the data, then when it comes to writing it to the newly created .wav file I get an error like: 
  Error1: javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream
  Error2: could not get audio input stream from input stream</p>
  
  <p>The code is:</p>
  
  <pre><code>    try
      {
      String path = "*********";
      String path2 = path + "newFile.wav";
  
      File filePath = new File(path);
      File NewfilePath = new File(path2);
  
      String [] folderContent = filePath.list();
  
      int FileSize =  0;
  
      for(int i = 0; i &lt; folderContent.length; i++)
          {
              RandomAccessFile raf = new RandomAccessFile(path + folderContent[i], "r");
              FileSize = FileSize + (int)raf.length();
  
          }
  
      byte[] FileBytes = new byte[FileSize];
  
      for(int i = 0; i &lt; folderContent.length; i++)
          {
              RandomAccessFile raf = new RandomAccessFile(path + folderContent[i], "r");
              raf.skipBytes(44);
              raf.read(FileBytes);
              raf.close();
  
          }
  
      boolean success = NewfilePath.createNewFile();
  
      InputStream byteArray = new ByteArrayInputStream(FileBytes);
  
      AudioInputStream ais = AudioSystem.getAudioInputStream(byteArray);
  
      AudioSystem.write(ais, Type.WAVE, NewfilePath);
  
      }
  </code></pre>