I am getting NullPointerException in the code.I want to handle it. In the following code i have specified the line in which the null pointer exception occurs.
public static void mapPcm16bitLittleEndian2Float(final byte[] pcm16bitBytes,
final int offsetInput,
final float[] samples,
final int offsetOutput,
final int length) {
if (pcm16bitBytes.length - offsetInput < 2 * length) {
throw new IllegalArgumentException("Insufficient Samples to convert to floats");
}
if (samples.length - offsetOutput < length) {
throw new IllegalArgumentException("Insufficient float buffer to convert the samples");// Getting null pointer exception here.
}
for (int i = 0; i < length; i++) {
samples[offsetOutput + i] = ((pcm16bitBytes[offsetInput + 2 * i] & 0xff) | (pcm16bitBytes[offsetInput + 2 * i + 1] << 8)); // no & 0xff at the end to keep the sign
}
and
public boolean processData(final byte[] data,
final int offset,
final int len) {
// converty raw bytes into float samples
mapPcm16bitLittleEndian2Float(data, offset, rawData, 0, len / 2);// getting null pointer exception
// encode the bitstream
return processData(rawData, len / 2);
}
Please help me getting out of this.