Determining the Encoding of a Sampled Audio File try { // From file // The next three lines should be in one line AudioInputStream stream = AudioSystem.getAudioInputStream( new File("audiofile")); // From URL stream = AudioSystem.getAudioInputStream( new URL("http://hostname/audiofile")); AudioFormat format = stream.getFormat(); if (format.getEncoding() == AudioFormat.Encoding.ULAW) { } else if (format.getEncoding() == AudioFormat.Encoding.ULAW) { } } catch (MalformedURLException e) { } catch (IOException e) { } catch (UnsupportedAudioFileException e) { // Audio format is not supported. }