permaculture playing cards*
The moose likes I/O and Streams and the fly likes I want to get a file from a folder on the server using RMI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "I want to get a file from a folder on the server using RMI" Watch "I want to get a file from a folder on the server using RMI" New topic
Author

I want to get a file from a folder on the server using RMI

Mustafa Segun
Greenhorn

Joined: Jan 19, 2010
Posts: 18
I wanted to read a file from a folder on a server program which i happened to be using RMI. Is there a standard way of reading the file and store it on the client system ?
Please help !


SCJP, SQL EXPERT, OCMJD
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18886
    
    8

There are several standard ways for getting files from folders, but they generally don't involve RMI. There's FTP, which was specifically designed for that, and then there's HTTP, which wasn't specifically designed for that but does have features which support it.

But RMI? That's Remote Method Invocation, remember? To have it transfer a file, you would have to produce an object with a method which returned the entire contents of the file, most likely as a byte array. This would require storing the entire file in memory before transmitting systems, which is a bad idea as it limits the size of the file which can be transmitted. So I would consider RMI a poor choice for file transfer.
Mustafa Segun
Greenhorn

Joined: Jan 19, 2010
Posts: 18
@Paul Clapham...
Thanks so much for the response... how can i implement the ftp way of transfering these files from the server's AbsolutePath to the Client's AbsolutePath
I will really appreciate it if you put me through a simple model
Thanks in advance
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18886
    
    8

If you download Apache Commons Net you'll find it supports FTP clients. I'm assuming you have already confirmed that there is an FTP server running on the server you were talking about, and that you will have access to the desired file via that FTP server.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

I would definitely try Paul's suggestions first. However, back in the old days of Java ... I'm thinking around 1998 ... I made a RemoteFileSystemView implementation of the javax.swing.filechooser.FileSystemView, which plugs into a JFileChooser. I can't remember the details, but I know it did work, and I made both an RMI and raw socket version. Both required a corresponding Java application to be running on the remote machine. Swing was in flux in those days, and I had to make some tweaks to make everything work. The Swing developers actually incorporated the tweaks into the code base, so that's my one and only contribution to the Java API, assuming it's even still there.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I want to get a file from a folder on the server using RMI