If you want, you can predict your movement with the Periodic Interference Test (PIT), which is fancy for "Place myself in the next position and if I collide with something, revert me to the last safe position". This is fast, easy, relativly safe and should be sufficient for your game as long as you don't move to fast (aka make two big jumps in a frame).
However: I can guarantee you that you never will come as close as possible to your obstacle. Simply the fact that you make jumps of a fixed size guarantees that you are somewhere in the Interval
[0,stepSize) next to your target.
If you want the best possible answer, use Predicted Instant of Collision (PIC). This will compute your way before you actually take your step, and, if it finds an obstacle, moves you only as close as possible without colliding the obstacle. This will bring your Player nearly to
0 distance to the obstacle.
However No. 1: This works only for linear pathes! For a solution for non-linear pathes relate to this question at stackoverflow.
However No. 2: PIC is relativly trivial for round objects (disk/spheres). You seem to use a Square as player, which might lead to a problem. You can use a bounding disk around your Square to get close and then use really small steps to approach the obstacle (aka a tiny PIC).
A good explanation for PIT and PIC can be found here and here.
An alternate solution is described here