last 3 letters are length() - 3
to length()
(the second parameter is implicitely length(), so it is not necessary)
param2.substring(params2.length() - 3)
however, you could use endsWith
which is clearer :
param2.endsWith("pdf")
which does exactly that.