For your 1st question how are you connecting to remote server RMI, sockets, others?
2nd question no, if you can access it meaning able to read it and storing it in a list in memory then once you done reading your list object will have the data from the remote file. Then you can use the list to produce a local copy if needed and do manipulation.
3rd question kind of answered. if you can connect to remote server then you are set. BTW RMI can use security manager to do a whole lots of stuff and depending on what security constraints you are referring to, it's hard to say.
1) You can use FTP, Windows file sharing (a.k.a. SMB), or if it's read-only perhaps even HTTP. You can also use RMI but that would require some more work, but it's not impossible (my own FileTransferRemote and FileTransferRemoteObject have proven that ).
2) in the end yes, you will need to download it. Perhaps not as you mean with transferring the file first, then reading, but even if you are reading it directly from the remote location you are still downloading its contents when you read it.
You don't need to download SMB for Windows; it's already built in. It's the official name for Windows file sharing. For Linux and Unix you should check out your distribution's package system for "samba".
With Java you can use File with FileReader with files located on shares; for instance, new File("\\\\machine\\share\\myfile.txt"). Note the 4 backslashes at the start; that's because the two backslashes from the protocol are escaped for Java.
Now this will only work if you have access to that share without an additional need for a username and password. Otherwise you should check out JCIFS.
As for accessing Windows shares from Linux / Unix, I haven't tried that ever before so I couldn't tell you how that works.
If you cannot get the Windows shares working you can also use FTP. With a third party library like Apache Commons Net or JvFTP you can access files on an FTP server, and get InputStreams and OutputStreams to those.
Thanks Randi, Looks like we've got something interesting here. However, is there any constraints for this to work? In terms of ports being open, or a VPN access or something like that? Why I ask this question is because, the remote computer is on a different Domain than mine!!
Thanks a lot
Joined: Feb 21, 2009
No special setup should be needed.
You will need read access to the remote file being read. Try first, just to read the file with the simple cat command as follows - try the various addressing formats I specified in the previous post.
If the command succeeds, you have read access. Then you can use any scripts with that file.