943,708 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 612
  • Java RSS
Jul 3rd, 2009
0

I need a class in Java API...

Expand Post »
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.
Similar Threads
Reputation Points: 72
Solved Threads: 26
Posting Whiz in Training
GDICommander is offline Offline
209 posts
since Jun 2008
Jul 3rd, 2009
0

Re: I need a class in Java API...

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.
Featured Poster
Reputation Points: 1907
Solved Threads: 950
Posting Expert
JamesCherrill is offline Offline
5,768 posts
since Apr 2008
Jul 4th, 2009
1

Re: I need a class in Java API...

> 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.
Last edited by ~s.o.s~; Jul 4th, 2009 at 4:02 pm.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Jul 4th, 2009
0

Re: I need a class in Java API...

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.
Featured Poster
Reputation Points: 1907
Solved Threads: 950
Posting Expert
JamesCherrill is offline Offline
5,768 posts
since Apr 2008
Jul 5th, 2009
0

Re: I need a class in Java API...

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. :-)
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: subversion problem
Next Thread in Java Forum Timeline: JComponent Placement





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC