Home > Java > JavaBase > body text

How to determine whether a file exists in java

Release: 2019-11-21 11:26:32
Original
5637 people have browsed it

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";
}
}
Copy after login

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 )
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template