Java – native JDK code for copying files
•
Java
Is there native JDK code to copy files (buffers, streams, or others)?
Solution
If "native" is used to represent "part of Java standard API" (instead of platform related code, it is usually called "native" in the Java World), "Copy file" means "take the single method of the file" and the target path and generate a copy of the file content. "Then no, there is no such method in the standard API. You must open an InputStream and an OutputStream (you can choose to get a more efficient filechannel) and use the buffer to transfer bytes. See Apache commons io for a convenient single call method
Update: since Java 7, the file copy function has become Java nio. file. Files is part of the standard API
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码