How to check if a directory exists?
So you can check the existence of a directory or just the existence of a file?
File file = new File(filepath); if (file.exists()) { ... } How to check if a directory exists?
So you can check the existence of a directory or just the existence of a file?
File file = new File(filepath); if (file.exists()) { ... } You can check the existence of a folder or file as follows:
import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; ... Path path = Paths.get("E:\\NecessaryFolder"); if (Files.exists(path)) { // действия, если папка существует } ... Read more about this here: docs.oracle.com .
Similar question: How to check if a folder exists .
And also here: click .
Source: https://ru.stackoverflow.com/questions/635217/
All Articles