JAVA无法获取磁盘中文件的物理地址吗?

时间:2016-10-25 22:51:52

标签: java

JVM中有内存限制。如果我想读取大小超过1GB的大文件,请将其保存到其他位置,以免改变JVM的虚拟内存。

1 个答案:

答案 0 :(得分:1)

是时候阅读Files.move()上的文档了。您不需要将文件读入内存......

  

或者,假设我们要将文件移动到新目录,   保持相同的文件名,并替换它的任何现有文件   目录中的名称:

Path source = ...
Path newdir = ...
Files.move(source, newdir.resolve(source.getFileName()), REPLACE_EXISTING);

参数:

  

来源

the path to the file to move target - the path to the target file (may be associated with a different provider to the source path) 
  

选项

options specifying how the move should be done

<强>返回

the path to the target file