Greg Charles wrote:I think of a file descriptor as an integer. Technically, it's an index into a kernel data table of currently opened files, but even to a C programmer it's just a return value from certain system calls, which might need to be passed as a parameter to other system calls. A file handle is a higher level data structure in C, but it probably contains a file descriptor in it. To be fair, there's some muddling of the terms file descriptor and file handle in different operating systems and programming languages. In Java, we work at a higher level even than file handles.
In any case, while file handles and file descriptors are relevant to open files, Java's File object just provide certain operations on file system files, without necessarily opening them. You can't write to a file or read from it through the File methods, so there may not be a file handle even created for it in the underlying OS. Now if your File is a directory entry, and you call, say, listFiles() on it, the OS may get a file handle to it, then use that to read the list of files. However, it would then close the file and dispose of the file handle.
Thanks for the explain. It's helpful!