H
H
hHup2018-04-06 23:18:48
Java
hHup, 2018-04-06 23:18:48

How to check the existence of a file in java?

In general, I need to check for the existence of a file using only the path to that file, without resorting to File file=new File(), is that possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kornachev, 2018-04-07
@TopMetaFizick

String sPath = "путь к файлу";
Path path = Paths.get(File(sPath ).toURI());
boolean exist = Files.exists(path);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question