Why doesn't Java have a copy of the file?

Why doesn't Java have a file copy method? It seems like such an obvious thing, and it saves people from writing things like this example .

+4
source share
4 answers

The Java API is missing more than just copying files. You might be interested in checking out the Apache Commons libraries. For example, the IO FileUtils library provides file copy methods.

+13
source

My guess is that when the File io system was written, they decided that they did not want to understand cross-platform problems with copying files and pinting - that is, they say: "This is doable by others, and this is not so common."

One thing to keep in mind about Java is that it is cross-platform, so some things are more complicated due to this reality.

+7
source

java.io.File is a relatively simple class introduced in 1.0. This was not the case in JDK 1.0 - this is mainly due to applet support and the javac compiler. I assume that there was not much pressure to expand it - applets and enterprise software are not oriented in this direction.

However, batches were added to the I / O for JDK7. Including [ java.nio.file.Path.copyTo ] [1].

[1]: http://download.java.net/jdk7/docs/api/java/nio/file/Path.html#copyTo(java.nio.file.Path , java.nio.file.CopyOption ... )

+6
source

For the same reason, Java doesn't have many other things. which are ultimately implemented by external libraries. I'm sure you can easily find such a library , or you can write a function.

+2
source

All Articles