public class Xfile extends Object
Note: this object will try to send any file the client requests, therefore it should either be used by trusted clients, or with access priviliges appropriately locked down. Another option is to override the open method in a subclass, to check the requested resource against an approved list, throwing an exception if not.
| Modifier and Type | Field and Description |
|---|---|
static boolean |
remoteInvoke
This field can allow the static fetch method to be invoked by a remote
client.
|
| Constructor and Description |
|---|
Xfile(int maxBlock)
The constructor simply sets the maximum transfer block size.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
fetch(Object item,
String source,
String dest)
This is the only method used by clients, it fetches the file from the
specified source, and saves it to the specified destination.
|
byte[] |
nextBlock()
This method is called by the client's static fetch method, to request
subsequent blocks of the file, until the transfer is complete.
|
void |
open(String source)
This method is called by the client's static fetch method, to open a
resource on a remote Java Virtual Machine.
|
public static boolean remoteInvoke
public Xfile(int maxBlock)
maxBlock - The largest possible block to return from the
nextBlock method. It is suggested not to exceed 64k bytes.IllegalArgumentException - if the max block argument is
less than 256 bytes, or greater than 1MB.public void open(String source) throws IOException
source - The resource to be loaded, typically the path and name
of the file on the server's local filesystem.IOException - If the specified resource does not exist, or
cannot be opened.public byte[] nextBlock()
throws IOException
IOException - If a stream is not currently open, or if a read,
or close error occurred.public static void fetch(Object item, String source, String dest) throws Exception
As a special case; the source and/or destination arguments can be URLs.
For example:
item - The object, presumably a remote reference to an Xfile
object, with which to fetch the resource.source - The file resource, typically the path and name of the
file in the server's local filesystem, to be transferred.dest - The resource, typically the path and name of the file
in the clients's local filesystem, in which to transfer the data.
If the destination is local, and the path does not exist, it will
attempt to create it automatically.IOException - If the source is invalid, the destination
is invalid, or either could not be opened. If the destination
already exists, it will be overwritten.RemoteException - If a remote method invocation,
involved in the data transfer, fails.IllegalAccessException - If this method is being invoked by a
remote JVM, and remote invocation has not been enabled.Exception - By the remote JVM, if the operation is not
supported.Copyright © 2016. All Rights Reserved.