Home  >  Article  >  Java  >  How to determine whether a file exists in java

How to determine whether a file exists in java

尚
Original
2019-11-21 11:26:325577browse

How to determine whether a file exists in java

java determines whether a file exists:

public static String fileExists(String plainFilePath){
File file=new File(plainFilePath);
if(!file.exists()) {
return "false";
} else{

return "true";
}
}

file_exists is a function whose Chinese name is to check whether a file or directory exists. (If under Linux. The permission of the parent folder that needs to be detected is not 777, false will be returned)

bool file_exists ( string filename )

If the file or directory specified by filename exists, it will return TRUE, otherwise it will return FALSE.

In Windows, use //computername/share/filename or \\computername\share\filename to check shared files on the network.

For more java knowledge, please pay attention to java basic tutorial.

The above is the detailed content of How to determine whether a file exists in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn