Java – native JDK code for copying files

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
分享
二维码
< <上一篇
下一篇>>