Help. Having dtmf dropout on longer inputs > 3

I am having capturing all the digits pressed when a I require that lets say 5 digits are entered. My code snippet is show here:

maxdtmf = maxdtmf-1;
if(maxdtmf<0)
{
maxdtmf=0;
}

if(maxdtmf>0)
{
sb.append(channel.getData("/mnt/Library/dtmffile", Long.parseLong(curpromptObj.getpromptRecMaxTime()), maxdtmf));
}

Now this method works sometimes and captures all the digits, but it often drops one or two digits in the middle especially with input strings 5 or longer. Is there something wrong with this method or is there a better way to approach receiving digits?

Thanks ahead.