Doesn't sound like a Java question to me; more of a general character recognition algorithm question...

If you find an appropriate algorithm and have trouble coding it in Java we may be able to...