5
I’m trying to check if a directory typed in JTextField
exists or not. I tried to use Files.notExists()
but the first argument must be of the type Path
and I couldn’t figure out how to convert from String
.
String caminho = txtDirIndexado.getText().replace("\\", "\\\\");
if (Files.notExists(caminho, LinkOption.NOFOLLOW_LINKS)) {
}
I’m getting the following message in Eclipse: Multiple markers at this line - path cannot be resolved to a variable - The method exists(Path, Linkoption...) in the type Files is not applicable for the Arguments (File, Linkoption)
– Matt S
@Strokes,
caminho
, in the answer above is a variable. You need to initialize it to use. An example:String caminho = "C:\UmDiretorio";
. Change your code and try again.– humungs
Yes, I know that. I adapted it for my code but it keeps giving this error. The @Leonardo Otto example worked.
– Matt S