| | |
I need a class in Java API...
Thread Solved |
Hello everyone!
I'm developping a chat application in a client/server context and every client has a shared directory. I want the server to know the directory structure of each shared directory of every client. I'm asking myself if there's an existing class in the Java API that can keep a directory structure on the server side, without containing the entire files.
I was thinkning of the File class, but it seems to work with a "real" file system on a "client side". I'm only interested for the structure of the shared directory (directory names and file names). So, if someone knows the existence of a class that can satisfy my needs, I would like to know. Otherwise, I will have to code a DirectoryTree class.
I'm developping a chat application in a client/server context and every client has a shared directory. I want the server to know the directory structure of each shared directory of every client. I'm asking myself if there's an existing class in the Java API that can keep a directory structure on the server side, without containing the entire files.
I was thinkning of the File class, but it seems to work with a "real" file system on a "client side". I'm only interested for the structure of the shared directory (directory names and file names). So, if someone knows the existence of a class that can satisfy my needs, I would like to know. Otherwise, I will have to code a DirectoryTree class.
•
•
Join Date: Apr 2008
Posts: 971
Reputation:
Solved Threads: 146
You can use the File class wherever the "real" files are, but as soon as you have a File object for a directory that provides the list of files you can use your existing sockets to write/read the object via the socket stream. Once you have a copy of it at the far end you should be able to use its methods to peruse the file list. (But I haven't actually tried this myself!)
Last edited by JamesCherrill; Jul 3rd, 2009 at 2:51 pm.
> but it seems to work with a "real" file system on a "client side".
I'm not really sure what you mean by a `real' file system; the File class provides an `abstract filesystem independent view' of the path names i.e. your File object does *not* map to a real file on your file system. It's more of an abstraction provided to deal with `file' resources represented using path names.
BTW, I'm personally in favor of having a separate application specific class to represent a File or Directory structure. At first it might end up being just a thin wrapper for the File class but as and when features are added, it would serve as a good abstraction for containing all `File' or `Directory' specific state and behavior of your application.
I'm not really sure what you mean by a `real' file system; the File class provides an `abstract filesystem independent view' of the path names i.e. your File object does *not* map to a real file on your file system. It's more of an abstraction provided to deal with `file' resources represented using path names.
BTW, I'm personally in favor of having a separate application specific class to represent a File or Directory structure. At first it might end up being just a thin wrapper for the File class but as and when features are added, it would serve as a good abstraction for containing all `File' or `Directory' specific state and behavior of your application.
Last edited by ~s.o.s~; Jul 4th, 2009 at 4:02 pm.
I don't accept change; I don't deserve to live.
•
•
Join Date: Apr 2008
Posts: 971
Reputation:
Solved Threads: 146
There's a complete re-work of the File model in the planning for Java 7 - you may find that interesting.
What I meant by "real" file system was simply that the File class relates to actual directory/file structures in an actual mounted file system on the same machine. Or more specifically, to paths within said structure. There's no guarantee that a File object's path will relate to an actual readable or writeable file, but you can assume that the path will be a valid path in a currently mounted file system.
I think this means that the current File class is exactly what you refer to as "specific class to represent a File or Directory structure" - that is all that File is, despite its misleading name. Once again, the discussions around the proposed new file IO classes really help to clarify all this.
What I meant by "real" file system was simply that the File class relates to actual directory/file structures in an actual mounted file system on the same machine. Or more specifically, to paths within said structure. There's no guarantee that a File object's path will relate to an actual readable or writeable file, but you can assume that the path will be a valid path in a currently mounted file system.
I think this means that the current File class is exactly what you refer to as "specific class to represent a File or Directory structure" - that is all that File is, despite its misleading name. Once again, the discussions around the proposed new file IO classes really help to clarify all this.
Yes, Java 7 indeed seems to bring a lot of interesting things to the table. More confusion FTW!
> What I meant by "real" file system was simply that [...]
My explanation was actually aimed at the OP since I thought he was getting confused between the `File' class and the file-system file. :-)
> What I meant by "real" file system was simply that [...]
My explanation was actually aimed at the OP since I thought he was getting confused between the `File' class and the file-system file. :-)
I don't accept change; I don't deserve to live.
![]() |
Similar Threads
- is it possible for PHP to call API written on java ? HELP (Java)
- Print different format files using java API (Java)
- i need java API for the EEG signal... please (Java)
- SMS Java API (Java)
- How to replace repeated substring in other string? (Java)
- String Class Of Java (Java)
- Read and write to an ASCII Text file (Java)
Other Threads in the Java Forum
- Previous Thread: subversion problem
- Next Thread: JComponent Placement
| Thread Tools | Search this Thread |
-xlint actionlistener android api applet application array arrays automation bi binary blackberry block bluetooth character class client code compile compiler component consumer database desktop developmenthelp eclipse error fractal freeze ftp functiontesting game gameprogramming givemetehcodez graphics gui health html ide image integer j2me j2seprojects java javac javaee javaprojects jetbrains jni jpanel jtable julia learningresources lego linked linux list mac main map method methods mobile myregfun netbeans notdisplaying number online printf problem program project qt recursion researchinmotion rotatetext rsa scanner screen server set singleton sms sort spamblocker sql string swing system textfields threads time title tree tutorial-sample update variablebinding windows working xor






