[Solved] How to Check if the File Name is already exists or not? [duplicate]


To see if a file name exists simply check it as follow:

File file = new File(filePath);
if (file.exists()) { 
    // do something
}

Note that the file can be also a directory, not necessarelly a true file.
If you need also to check if it is a file:

File file = new File(filePath);
if (file.exists() && !file.isDirectory()) { 
    // do something
}

solved How to Check if the File Name is already exists or not? [duplicate]