Dear all,
I'm implementing a Java-based system which needs accessing both the native and networked filesystems. Using the Java File class is easy and straight forward in the native case, and I'd like to keep this consistency to user even the filesystem is connected over the network.
e.g. File folder = new File("some_folder"); File[] files = folder.listFiles();
if the instance "folder" is network-attached, the folder.listFiles()
will trigger the related network transaction to retrieve the remote file structure.
The problems include, is it possible to extending the File class with the same name? If a new given name for the subClass is needed, e.g. NetedFile
, how to deal with the return type in the methods like File[] listFiles()
while I don't want to wrap the element from File
to NetedFile
one-by-one.
Please kindly advise.
Thanks & regards, William Choi