File operations are very basic and important content in the program, while paths, files, directories, and I/O are common topics in file operations, I would like to summarize these common problems and try to provide some solutions for each problem.
File operations are very basic and important in the program, and the path, files, directories and I/O are common topics in the file operation, here want to summarize these common problems, for each problem, as far as possible to provide some
Path strings are manipulated by path
Get suffix
Can merge paths
Get file name
Directory operations by directory and DirectoryInfo
To determine whether a directory exists
Create a table of contents
Delete Directory
Get all subdirectories under
Java gets the system path font, obtains all the file names under a directory, gets the current path
Copy Code code as follows:
Package com.liuxing.test;
Import java.awt.GraphicsEnvironment;Import Java.io.File;public class Test {
many times when using the Linux shell, we need to handle the file name or directory name, the usual operation is to extract the file name from the path, extract the directory name from the path, extract the file suffix name, and so on. For example,
Using unityengine;using system.collections;using system.collections.generic;using System.IO;public static list NameArray = new list ();///returns all file names under this path under the specified assets file path//////// file name Array ///assets
First, use ${}1, ${var##*/}The purpose of this command is to remove the variable var from the left side of the last '/' character and its left side of the content, return from the left side of the last '/' (excluding the character) to the right of
1:OS. Listdir (PATH) // path is the Directory
The function is equivalent to executing the Dir command in the path directory. The returned result is of the list type.PrintOS. Listdir ('..')
2:OS. Path.Walk(Path, visit, ARG)
Path: the
Python reads all file names under the specified directory and its subdirectories
Target
As you accumulate more and more files on your disk, searching for a file is too slow and memory-using Windows. Therefore, I want to find a file name that can
Read Catalogue
Begin
Path action on a string of pathsGet suffixCan merge pathsGet file nameDirectory and DirectoryInfo operations on directoriesDetermine if a directory existsCreate a DirectoryDelete DirectoryGet all subdirectories
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.