Issue
I'm having a bit of trouble clarifying the documentation around Java.io.File.
From Android docs:
Instances of this class may or may not denote an actual file-system object such as a file or a directory. If it does denote such an object then that object resides in a partition. A partition is an operating system-specific portion of storage for a file system. A single storage device (e.g. a physical disk-drive, flash memory, CD-ROM) may contain multiple partitions. The object, if any, will reside on the partition
To my understanding the File object is much like a path/pointer to a location in the file-system structure.
The bit about partitions is confusing me so,
When I call:
File file = new File(getFilesDir(),"myFileName.txt")
Is a new block of hard disk space being allocated for a new file-system object called "myFileName.txt" or not? ie.
Memory:
Documents
hats.png
After calling constructor:
Memory: OR Memory Partition Land:
Documents Documents myFileName.txt
hats.png hats.png
myFileName.txt
If not how/when does this file-system object called "myFileName.txt" get physically created?
Solution
To my understanding the File object is much like a path/pointer to a location in the file-system structure.
No. A File
encapulates a file name. Nothing more. It doesn't have to be the name of an existing file.
When I call:
File file = new File(getFilesDir(),"myFileName.txt")
Is a new block of hard disk space being allocated for a new file-system object called "myFileName.txt" or not?
Not.
If not how/when does this file-system object called "myFileName.txt" get physically created?
When you do one of the following:
- call
File.createNewFile()
(mostly unnecessary unless you like zero-length files) - use the
File
in the constructor of aFileOutputStream
orFileWriter
, orRandomAccessFile
withw
in themode
parameter. - use it indirectly via a
Path
to construct one of the above or aFileChannel
.
Answered By - user207421
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.