如何在java.io.File对象中更改文件路径位置 [英] How to change file path location in java.io.File object

查看:69
本文介绍了如何在java.io.File对象中更改文件路径位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题说明了一切.我有一个指向/home/user/filename1 的File对象.

The question says it all. I have a File object which is pointing to /home/user/filename1.

如果我调用file.getAbsolutePath(),它将返回/home/user/filename1

If I call file.getAbsolutePath() then it would return /home/user/filename1

我的问题是-

  1. 我们可以将文件对象内部的路径更改为其他位置吗?
  2. 如果是,那怎么办?

谢谢

推荐答案

"File类的实例是不可变的;也就是说,一旦创建,File对象所表示的抽象路径名将永远不会改变."

"Instances of the File class are immutable; that is, once created, the abstract pathname represented by a File object will never change. "

从文件 javadoc 中.

这篇关于如何在java.io.File对象中更改文件路径位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆