2015-04-20 25 views
1

文件覆蓋文件的優點或主要功能是什麼?何時更喜歡一個&爲什麼?java.nio.file.Files和java.io.File之間的區別?

編輯:這只是我們這個世界中另一個'問題的區別 - 所以確保你真的想要降低它!

+1

'Files'是實用類保持用於管理文件系統中的靜態方法,'File'是實例表示單路徑(具有幾個額外的方法允許操作類這條路)。 – Pshemo

+1

檢查[這裏](https://blogs.oracle.com/slc/entry/javanio_vs_javaio)。 – SilentKnight

+1

@Kayman - 對不起,但如果你是對的,怎麼來http://stackoverflow.com/questions/40471/differences-between-hashmap-and-hashtable有1500+票? –

回答

2

Files

這類專門由該文件,目錄,或其他類型的文件進行操作的靜態方法。

但文件是文件和目錄路徑名的抽象表示

手段文件類是一個實用工具類,對文件進行操作。

1

按Java文檔,java.nio.file.Files class consists exclusively of static methods that operate on files, directories, or other types of files. In most cases, the methods defined here will delegate to the associated file system provider to perform the file operations.

鑑於java.io.File is an abstract representation of file and directory pathnames.