当前位置:网站首页>File operation serialization recursive copy
File operation serialization recursive copy
2022-07-03 07:10:00 【L gold p】
1、 File
1、1 summary
java.io.File class : Abstract representation of file and file directory paths , It's not about the platform
File It can be built 、 Delete 、 Rename files and directories , but File Can't access the file content itself .
If you need to access the file content itself , You need to use input / Output stream .
Want to be in Java A program that represents a real-life file or directory , Then there must be a File Yes like , however Java One of the procedures File object , There may not be a real file or directory .
File Object can be passed as a parameter to the constructor of the stream
1.2 Construction method
public File(String pathname) With pathname Create... For the path File object , It can be absolute path or relative path , If pathname Is a relative path , The default current path is in the system property user.dir Storage in .
Absolute path : It's a fixed path , Start with the drive
Relative paths : It's about starting from a certain position
public File(String parent,String child) With parent The path of fatherhood ,child Create... For the subpath File object .
public File(File parent,String child) According to a father File Object and sub file path creation File object
1.3 Common methods
Acquisition function :
public String getAbsolutePath(): Get absolute path
public String getPath() : Get path
public String getName() : Get the name
public String getParent(): Get the upper file directory path . If there is no , return null
public long length() : Get file length ( namely : Number of bytes ). Cannot get the length of the directory .
public long lastModified() : Get the last modification time , Millisecond value
public String[] list() : Get the name array of all files or file directories in the specified directory
public File[] listFiles() : Get all the files in the specified directory or file directory File Array
Rename function :
public boolean renameTo(File dest): Rename the file to the specified file path
Judgment function :
public boolean isDirectory(): Determine whether it is a file directory
public boolean isFile() : Determine if it's a document
public boolean exists() : Judge whether it exists
public boolean canRead() : Judge whether it is readable
public boolean canWrite() : Judge whether it is writable
public boolean isHidden() : Determine whether to hide
Create delete function :
public boolean createNewFile() : create a file . If the file exists , Do not create , return false
public boolean mkdir() : Create file directory . If this file directory exists , We won't create . If the upper directory of this file directory does not exist , It doesn't create .
public boolean mkdirs() : Create file directory . If the upper file directory does not exist , Create... Together
matters needing attention : If you create a file or the file directory does not have a drive letter path , that , Default in project Under the path .
public boolean delete(): Delete files or folders
Delete notes :
Java Delete in does not go to the recycle bin .
To delete a file directory , Please note that the file directory cannot contain files or file directories
1.4 Usage mode


1.5 Recursive replication
1 Copy
Is the combination of input and output
2 Get all sub files under the folder
If the sub file is a file , Copy
If the sub file is a directory, then obtain all the sub files of the directory , Do the same thing
Be careful :
When copying , The source directory and destination directory cannot be consistent


2、 Object flow
2.1 summary

2.2 Be careful 
The class to serialize must implement Serializable Interface , This interface is an identifier
This class can be serialized
2、3 serialize

2.4 Deserialization

2.5 serial VersionUID

2.6 Transient

边栏推荐
- RestHighLevelClient获取某个索引的mapping
- Architecture notes
- SecureCRT取消Session记录的密码
- 万卷书 - 价值投资者指南 [The Education of a Value Investor]
- mongodb
- Thoughts in Starbucks
- Practical plug-ins in idea
- Advanced API (multithreading)
- Advanced API (UDP connection & map set & collection set)
- "Baidu Cup" CTF game 2017 February, Web: blast-1
猜你喜欢
![[untitled]](/img/72/4ff9354634342580a135debb58b60e.jpg)
[untitled]

Interfaces and related concepts

Pytest -- write and manage test cases

The pressure of large institutions in the bear market has doubled. Will the giant whales such as gray scale, tether and micro strategy become 'giant thunder'?

High concurrency memory pool

Sorting, dichotomy

【已解决】Unknown error 1146

Setting up the development environment of dataworks custom function

10000小時定律不會讓你成為編程大師,但至少是個好的起點

Flask Foundation
随机推荐
3311. 最长算术
【最详细】最新最全Redis面试大全(50道)
Advanced APL (realize group chat room)
Deep learning parameter initialization (I) Xavier initialization with code
萬卷書 - 價值投資者指南 [The Education of a Value Investor]
Final, override, polymorphism, abstraction, interface
Software testing learning - day 3
Notes on the core knowledge of Domain Driven Design DDD
In depth analysis of reentrantlock fair lock and unfair lock source code implementation
熊市里的大机构压力倍增,灰度、Tether、微策略等巨鲸会不会成为'巨雷'?
Use the jvisualvm tool ----- tocmat to start JMX monitoring
Software testing assignment - the next day
Common APIs
4279. 笛卡尔树
Liang Ning: 30 lectures on brain map notes for growth thinking
Advanced API (UDP connection & map set & collection set)
10 000 volumes - Guide de l'investisseur en valeur [l'éducation d'un investisseur en valeur]
2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)
CentOS switches and installs mysql5.7 and mysql8.0
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization: