Home > Java > JavaBase > Java determines whether it is a folder

Java determines whether it is a folder

Release: 2019-11-20 16:00:25
Original
3102 people have browsed it

Java is an object-oriented programming language. It not only absorbs the various advantages of the C language, but also abandons the difficult-to-understand concepts such as multiple inheritance and pointers in C. Therefore, the Java language has two characteristics: powerful functions and simple and easy to use. .

Java determines whether it is a folder

isDirectory() in java checks whether an object is a folder. The return value is of type boolean. Returns true if so, false otherwise.

The calling method is: object.isDirectory() without specifying parameters.

Example:

String path="C:/windows/Help"; //我随便给的一个目录
File f=new File(path); //new的一个File对象
if(f.isDirectory()){ //如果path表示的是一个目录则返回true
....
}
Copy after login

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

The above is the detailed content of Java determines whether it is a folder. 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