What is the difference between AudioSystem.getAudioInputStream(InputStream) and new AudioInputStream(InputStream, AudioFormat, long)?
AudioSystem.getAudioInputStream(InputStream) “intelligently” parses the header of the file in InputStream and tries to retrieve the format of it. This fails for “raw” audio files or files that aren’t recognized by Java Sound. The AudioInputStream returned by this method is at the position where the actual audio data starts, the file header is skipped. AudioInputStream(InputStream, AudioFormat, long) is a “stupid” constructor that just returns an AudioInputStream with the InputStream used “as is”. No attempt is made to verify the format with the given AudioFormat instance – if you pass a wrong AudioFormat, the data in InputStream is interpreted in a wrong way. Using the second way on an InputStream that is obtained from an audio file would give an AudioInputStream where the “audio data” starts with the file header. Often, the difference won’t be noticable, because headers are typically short (typically 44 bytes for .wav files, 24 bytes for .au files). However, there is no quarantee that