May be generate this method with Idea tool? Because you can get NullPointerException on getPath().