I found the solution....
I use modular inversion. B = A^-1. B is the modular multiplicative inverse of A. And BigInteger class has a method called modInverse().
Code:
BigInteger b = a.modInverse(modulusUsedInAlgorithm)
Since im using modular, the fraction will be lost. So it can be represented as a Integer