It seemed to work when i tried it.
Tbh, i haven't seen the rest of your code so that might be it but. what i did was this:

public String checkString() {
String pdphrase = null;
try {
...