This article is a mirror article of machine translation, please click here to jump to the original article.

View: 13590|Reply: 1

[Source] Java recursively reads all file paths under the directory

[Copy link]
Posted on 1/10/2019 1:47:54 PM | | | |


The java code is as follows:

Attachment: Common operations for java files:

1. Get the file path and detection status:
1) Operation File path and name:
File getAbsoluteFile(): Get the absolute path
String getAbsolutePath(): Get the absolute path
String getPath(): Get the file path
String getName(): Get the file name
File getParentFile(): Gets the parent directory file
String getParent(): Get the parent directory path

2) How to detect the status of the file:
boolean canExecute(): Determine whether it is an executable file or not
boolean canRead(): Determine whether the file is readable
boolean canWrite(): Determine whether the file is writable or not
boolean isHidden(): Determine if the file is a hidden file
long lastModified(): Determines when the file was last modified

long length(): gets the length of the file in bytes



2. File method
1) File Operation:
boolean isFile(): whether it is a file or not
boolean createNewFile(): creates a new file
static File createTempFile(String prefix, String suffix): Creates a temporary file
boolean delete(): deletes the file
void deleteOnExit(): deletes files when the JVM stops
boolean exists(): Determine if a file exists
boolean renameTo(File dest): Re-modify the name

2) Catalog operation
boolean isDirectory(): Determine whether it is a directory
boolean mkdir(): creates the current directory
boolean mkdirs(): Creates the current directory and the parent directory
String[] list(): Lists all file names
File[] listFiles(): Lists all file objects
static File[] listRoots(): Lists the system keys





Previous:Please read "Security" section of the manual to find out how...
Next:YouCore Thinking Training: Solve problems with frameworks
 Landlord| Posted on 1/10/2019 2:06:50 PM |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com