I need a class in Java API...

Thread Solved
Reply

Join Date: Jun 2008
Posts: 147
Reputation: GDICommander is an unknown quantity at this point 
Solved Threads: 19
GDICommander's Avatar
GDICommander GDICommander is offline Offline
Junior Poster

I need a class in Java API...

 
0
  #1
Jul 3rd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 964
Reputation: JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice 
Solved Threads: 143
JamesCherrill JamesCherrill is offline Offline
Posting Shark

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

 
0
  #2
Jul 3rd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,581
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 461
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

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

 
1
  #3
Jul 4th, 2009
> 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.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 964
Reputation: JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice 
Solved Threads: 143
JamesCherrill JamesCherrill is offline Offline
Posting Shark

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

 
0
  #4
Jul 4th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,581
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 461
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

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

 
0
  #5
Jul 5th, 2009
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. :-)
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC