question: private static byte [ ] convertAudioEndianness ( byte [ ] audioData , boolean twoByteSamples ) { ByteBuffer out = ByteBuffer . allocate ( audioData . length ) ; out . order ( ByteOrder . nativeOrder ( ) ) ; ByteBuffer in = ByteBuffer . wrap ( audioData ) ; in . order ( ByteOrder . LITTLE_ENDIAN ) ; if ( twoByteSamples ) { ShortBuffer outShort = out . asShortBuffer ( ) ; ShortBuffer inShort = in . asShortBuffer ( ) ; while ( inShort . hasRemaining ( ) ) { outShort . put ( inShort . get ( ) ) ; } } else { while ( in . hasRemaining ( ) ) { out . put ( in . get ( ) ) ; } } out . rewind ( ) ; if ( ! out . hasArray ( ) ) { byte [ ] array = new byte [ out . capacity ( ) ] ; out . get ( array ) ; out . clear ( ) ; return array ; } return out . array ( ) ; }
target:  Converts the endianness of an AudioBuffer to the format required by the JRE.