it will fail if relativePath is directory path not file. Either add check for file.isDirecotry() or check method name to getAbsolutePathForFile