---
title: "Comment by Wellington Domiciano on \"Check if file exists at given path using Java and create if NOT\" | Hashnode"
description: "Nice! I like to use the Files utility class, look: import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths"
url: "https://hashnode.com/posts/check-if-file-exists-at-given-path-using-java-and-create-if-not/608e0509a3716542f363fb3b/comment/6090276cdc886b4318007f9e"
---

[Discussion](https://hashnode.com/posts/check-if-file-exists-at-given-path-using-java-and-create-if-not/608e0509a3716542f363fb3b)

Comment [Check if file exists at given path using Java and create if NOT](https://hashnode.com/posts/check-if-file-exists-at-given-path-using-java-and-create-if-not/608e0509a3716542f363fb3b)

[Wellington Domiciano](https://hashnode.com/@wldomiciano)

[May 3, 2021](https://hashnode.com/posts/check-if-file-exists-at-given-path-using-java-and-create-if-not/608e0509a3716542f363fb3b/comment/6090276cdc886b4318007f9e)

Nice! I like to use the [`Files`](https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/nio/file/Files.html) utility class, look:

```
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
  public static void main(String... args) throws IOException {
    final Path path = Paths.get(System.getProperty("user.dir"), "Report.html");

    if (Files.notExists(path))
      Files.createFile(path);
  }
}
```

[Amit Sahu](https://hashnode.com/@qa-amitsahu)

[May 3, 2021](https://hashnode.com/posts/check-if-file-exists-at-given-path-using-java-and-create-if-not/608e0509a3716542f363fb3b/comment/6090276cdc886b4318007f9e#reply-60902933dc886b4318007fe0)

Good approach! this also serves our purpose. [Wellington Domiciano](https://hashnode.com/@wldomiciano)
