remote file access : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

remote file access
The java.io.File class won’t let you read or write files on some other remote machine, e.g. Applets can’t read or write files on the server, even if they are signed. The File class in an application may let you read or write files on some other machine on a LAN (Local Area Network), but that depends on the underlying operating system to make the files on the other workstations on the LAN look those files like local files. It won’t do you any good to concoct filenames that look like URLs (Uniform Resource Locators). The File class is only for reading local files!
Introduction Learning More
Count the Ways Links
Books

Introduction

But why? Why can’t you just use an URL (Uniform Resource Locator) as your filename, and read and write files on some remote machine? The problem is you don’t want people out on the Internet reading and writing your files, or files on your server, without monitoring very carefully just what they are doing. You don’t want to give any old Tom, Dick or Harriet out on the Internet the keys to read or write any file on your system whenever they want.

Unfortunately, the Java file system has no security features. There is no way to identify yourself, to prove your identity, or to limit your read/write access to a given set of files or directories. It presumes unlimited read/write access. This is just not good enough for remotely reading and writing files.

Servers typically don’t provide a means for remote machines to directly read or write their files. When they do, such as in Novell NFS (Novell File System) servers, there is a whole layer of security tacked on top.

Instead, servers provide a pot pourri of indirect ways to read and write the remote files. In each case you run some program on the server that talks via the Internet to the remote computer, and does any file reading and writing on its behalf, e. g.

Let Me Count the Ways

Ways of Remotely Accessing Information
Technique Elaboration Pros Cons
JWS (Java Web Start) + HTTP (Hypertext Transfer Protocol) HTTP GET allows reading of a selected set of files, HTTP POST lets you send a query and get back information. HTTP PUT lets you upload a file, though the PUT feature is rarely supported. You write an Applet, signed Applet, Java Web Start or application to simulate a browser. Your client program can tie into a conventional Servlet system without having to change the Servlet system. You can also modify the servlet system to have a more efficient computer-friendly interface, (perhaps with auxiliary raw sockets). The Applet etc. presents a much crisper UI (User Interface) to the end user than browser would. The client must have Java installed and enabled. Sometimes corporations mindlessly block even the safest Applets in their paranoia.
browser + CGI (Common Gateway Interface)/Servlets Lets you communicate with Servlets running on the server that will read or write files for you and send back results. See Base64 and URLEncoded to convert your binary data to armoured printable characters. Most common technique. Does not require anything other than a browser installed at the client. This is the biggest plus. Clumsy user interface limited by browser and HTTP forms.
RMI (Remote Method Invocation) Lets you send Java objects back and forth between the remote computer and a server. Each can run methods on the other published objects. These methods may read and write files. Extremely flexible communications High overhead. Complicated to set up. Java only. Must have Java installed on the client and firewalls permeable to RMI.
Sockets let you send raw streams of bytes back and forth between remote machine and server. The program on the server can then use that information to read and write files. If you compress your data, this about as efficient as it gets. compact, efficient, low level. This is the way to pump large volumes of data. Pooling connections is complicated. You can’t afford to keep open idle sockets for every user.
Ajax You use traditional Servlets, with JavaScript assist on the client to give a richer UI. Makes the user interface more responsive to the user, particularly in catching errors before results are transmitted. Lack of standards. Requires different code for every browser. Mickey mouse coding language makes maintenance difficult.
XML (extensible Markup Language) You exchange XML (sometimes SOAP (Simple Object Access Protocol) ) messages between client and server. Allow sending tree-structured messages. Bloats the size of the messages to many times what they need to be, thus slowing down communications. They are thus suited only for short messages or low volumes. Messages need overly complicated tools to create and parse at each end.
CORBA (Common Object Request Broker Architecture) A heavy duty RMI that supports languages other than Java. It is considerably more complicated to use. Must create definition files for every possible interaction. Tedious. Ties into non-Java corporate CORBA systems.
EJBEnterprise Java Beans Are like RMI plus servlets, plus transaction logging and backout. They are an augmentation for Servlets. The client side can be anything a Servlet might support. Heavy duty corporate business logic. Complicated. Requires heavy duty servers.
FileTransfer classes From Canadian Mind Products. Let you copy files from a variety of sources, including jars, to a variety of targets, both remote and local. They use HTTP protocol where necessary. Very simple to use. Handles only files, not streams or transactions.
FTP (File Transfer Protocol) Allows file upload/download. For efficiency, send only zipped files, bundling many small files into one big one. FTP is a slower protocol than HTTP but supports recovery there is a disconnect in mid transfer. Supported almost everywhere. Supports only file transfer, no streams or transactions. It is for batch work.
JavaSpaces I’m told you can use this for intermachine communication, but I have never tried it.
JDBC JDBC (Java Data Base Connectivity) Lets you communicate with an SQL (Standard Query Language) server running on the server to read and write database files. Gives and Applet or JWS app complete power to do complex queries and updates, anything supported by JDBC. This exposes your database to the outside world in a way that invites hackers. It is safer do all your database work with Servlets, triggered by transactions coming in oven the Internet.
Jini I’m told you can use this for intermachine communication, but I have never tried it. This works with tiny devices as well as desktops. The technology seems to have stalled.
Pipes java.nio.channels.Pipechannels.Pipe. Under the hood these are Sockets useful for parent child process communication, not general Socket communication. Fast, simple. Regular java.io. PipedOutputStream pipes only work between Threads in a common JVM (Java Virtual Machine). They are not suitable for remote data access.
WebDAV A system to make a shared volume look like a local hard disk. Mainly used for sharing Microsoft Word documents. platform independent. Looks like ordinary HTTP to firewalls. Handles only batch sharing of files, no streams or transactions.
Each of these schemes has is own built-in security to be sure the general public can only see the files you want them too, and that authorised users can only indirectly read and write the files you want them too.

Books

book cover recommend book⇒Java P2P Unleashed: With JXTA, Web Services, XML, Jini, JavaSpaces, and EEto book home
by Robert Flenner, Michael Abbott, Toufic Boubez, Frank Cohen, Navaneeth Krishnan, Alan Moffet, Rajam Ramamurti, Bilal Siddiqui, Frank Sommers 978-0-672-32399-7 paperback
publisher Sams
published 2002-09-22
Covers a variety of the more exotic techniques for inter-computer communication with Java.
Australian flag abe books anz abe books.co.uk UK flag
Chinese flag amazon.cn amazon.co.uk UK flag
German flag abe books.de abe books.ca Canadian flag
German flag amazon.de amazon.ca Canadian flag
Spanish flag amazon.es Chapters Indigo Canadian flag
Spanish flag iberlibro.com abe books.com American flag
French flag abe books.fr amazon.com American flag
French flag amazon.fr Barnes & Noble American flag
Italian flag abe books.it Google play American flag
Italian flag amazon.it O’Reilly Safari American flag
India flag junglee.com Powells American flag
UN flag Kobo other stores UN flag
Greyed out stores probably do not have the item in stock. Try looking for it with a bookfinder.

Learning More

Oracle’s Javadoc on Pipe class : available:

This page is posted
on the web at:

http://mindprod.com/jgloss/remotefileaccess.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\remotefileaccess.html
logo
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.
no blog for this page
IP:[65.110.21.43]
Your face IP:[54.90.227.32]
You are visitor number