抽象路径在java.io中意味着什么? [英] What does abstract path means in java.io?

查看:281
本文介绍了抽象路径在java.io中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在java doc about

In java doc about

File#getPath()

写道:

 Converts this abstract pathname into a pathname string.

我尝试写1

File file3 = new File("D:\\work");
System.out.println(file3.getPath());

在cmd中我看到 D:\\work

我尝试写2:

File file4= new File("file4");
System.out.println(file4.getPath());

在cmd中我看到:

file4

因此我有一个问题:


抽象路径名

abstract pathname


路径名字符串

pathname string

推荐答案

抽象路径名 java.io.File object和路径名字符串 java.lang.String 对象。两者都引用磁盘上的相同文件。

An abstract pathname is a java.io.File object and a pathname string is a java.lang.String object. Both reference the same file on the disk.

我怎么知道?

Javadoc的第一句话 java.io.File 解释:

The first sentence of the Javadoc of java.io.File explains:


文件和目录的抽象表示路径名。

An abstract representation of file and directory pathnames.

它继续解释原因:


用户界面和操作系统使用依赖于系统的
路径名字符串来命名文件和目录。此类
提供了一个抽象的,与系统无关的分层
路径名视图。

User interfaces and operating systems use system-dependent pathname strings to name files and directories. This class presents an abstract, system-independent view of hierarchical pathnames.

这篇关于抽象路径在java.io中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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