文件和随机访问文件有什么区别?

时间:2022-06-02 00:24:20

what is the difference between file and random access file?

文件和随机访问文件有什么区别?

2 个解决方案

#1


A random access file is a file where you can "jump" to anywhere within it without having to read sequentially until the position you are interested in.

随机访问文件是一个文件,您可以在其中“跳转”到其中的任何位置,而无需按顺序读取,直到您感兴趣的位置。

For example, say you have a 1MB file, and you are interested in 5 bytes that start after 100k of data. A random access file will allow you to "jump" to the 100k-th position in one operation. A non-random access file will require you to read 100k bytes first, and only then read the data you're interested in.

例如,假设您有一个1MB的文件,并且您对在100k数据之后启动的5个字节感兴趣。随机访问文件允许您在一次操作中“跳转”到第100k位置。非随机访问文件将要求您首先读取100k字节,然后才读取您感兴趣的数据。

Hope that helps.

希望有所帮助。

Clarification: this description is language-agnostic and does not relate to any specific file wrapper in any specific language/framework.

澄清:此描述与语言无关,与任何特定语言/框架中的任何特定文件包装无关。

#2


Almost nothing these days. There used to be a time in certain operating systems where there were different types of files - some of which could be accessed randomly (at any point in the file) and others which could only be accessed sequentially. This made more sense when you were using a sequential medium such as tape. Any file system worth its salt these days only supports random access.

这几天几乎没有。在某些操作系统中曾经有过一段时间,其中存在不同类型的文件 - 其中一些可以随机访问(在文件中的任何位置),而其他文件只能按顺序访问。当您使用磁带等顺序介质时,这更有意义。如今,任何值得盐的文件系统都只支持随机访问。

#1


A random access file is a file where you can "jump" to anywhere within it without having to read sequentially until the position you are interested in.

随机访问文件是一个文件,您可以在其中“跳转”到其中的任何位置,而无需按顺序读取,直到您感兴趣的位置。

For example, say you have a 1MB file, and you are interested in 5 bytes that start after 100k of data. A random access file will allow you to "jump" to the 100k-th position in one operation. A non-random access file will require you to read 100k bytes first, and only then read the data you're interested in.

例如,假设您有一个1MB的文件,并且您对在100k数据之后启动的5个字节感兴趣。随机访问文件允许您在一次操作中“跳转”到第100k位置。非随机访问文件将要求您首先读取100k字节,然后才读取您感兴趣的数据。

Hope that helps.

希望有所帮助。

Clarification: this description is language-agnostic and does not relate to any specific file wrapper in any specific language/framework.

澄清:此描述与语言无关,与任何特定语言/框架中的任何特定文件包装无关。

#2


Almost nothing these days. There used to be a time in certain operating systems where there were different types of files - some of which could be accessed randomly (at any point in the file) and others which could only be accessed sequentially. This made more sense when you were using a sequential medium such as tape. Any file system worth its salt these days only supports random access.

这几天几乎没有。在某些操作系统中曾经有过一段时间,其中存在不同类型的文件 - 其中一些可以随机访问(在文件中的任何位置),而其他文件只能按顺序访问。当您使用磁带等顺序介质时,这更有意义。如今,任何值得盐的文件系统都只支持随机访问。