Put it in a method: public Artifact readArtifact(filePath) where Artifact is a class with groupId, artifactId, and version fields.