关于文件文件=新文件(路径) [英] About File file = new File(path)

查看:98
本文介绍了关于文件文件=新文件(路径)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java.iO.File 文档说了以下有关其构造器的内容,该构造器采用pathname:

The Java.iO.File document says the following words about its constructor which takes the pathname:

public File(String pathname)

通过转换给定的路径名​​字符串创建一个新的File实例 转换为抽象路径名.如果给定的字符串是空字符串, 那么结果就是空的抽象路径名.

Creates a new File instance by converting the given pathname string into an abstract pathname. If the given string is the empty string, then the result is the empty abstract pathname.

但是,如果pathname指向已经存在的文件,该怎么办?

But what if the pathname points to a file which is already existing?

File file = new File(PATH_TO_AN_EXISTING_FILE);

上面的file实例代表一个新的新文件(已删除现有文件吗?)还是它代表了一个现有文件?

Does the above file instance represent a fresh new file (with the existing one be deleted?) Or does it represent the existing file ?

推荐答案

文档所说的是它将创建一个新的File instance .这意味着它将在File类的内存中创建一个新实例.

What the documentation says is that it will create a new File instance. This mean it will create a new instance in memory of the File class.

此对象将指向文件系统上的文件.但是,如果文件存在,它将不会创建新文件.

This object will point to a file on you file system. However, if the file exists, it will not create a new file.

这篇关于关于文件文件=新文件(路径)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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