简体   繁体   English

Windows如何剪切文件,更改路径或传输完整数据

[英]how windows cuts a file, change path or transfer full data

I wonder how windows cuts a file into another location ? 我想知道Windows如何将文件剪切到另一个位置吗? does it change the file path only? 它仅更改文件路径吗? or transfer the whole file data? 或传输整个文件数据?

can you write a program in java to cut files in a fast way ? 您可以用Java编写程序来快速剪切文件吗?

When you use cut and paste with files, Windows will move the file if it's on the same device (disk partition, etc.). 当对文件使用剪切和粘贴时,如果文件位于同一设备(磁盘分区等)上,则Windows将移动文件。 That is, it will just update the file system's record, it won't have to copy the file data. 也就是说,它只会更新文件系统的记录,而不必复制文件数据。

You can use File#renameTo in Java to do the same thing, provided the OS can do so with the source and destination. 您可以在Java中使用File#renameTo进行相同的操作,前提是OS可以使用源和目标进行此操作。

If you cut and paste a file across devices, Windows has to copy the file data (of course), and then delete the old file. 如果跨设备剪切和粘贴文件,则Windows必须复制文件数据(当然),然后删除旧文件。 File#renameTo won't do that; File#renameTo不会这样做; the rename will fail (it'll return false ) and you have to respond to that by doing the file copy (and then removal of the old file) yourself. 重命名将失败(它将返回false ),您必须通过自己复制文件(然后删除旧文件)来对此进行响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM