|
Oracle | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.compoze.util.TemporaryFileClient
public class TemporaryFileClient
This is a client that connects to a temporary file server to write some data. It may be used to gain access to a file on the machine where the temporary file server is running, which is useful when you wish to pass data to a program running on another machine that may only read from local resources. The process for connecting to the server is as follows:
main()
method in this class (primarily just
for testing purposes), Java system properties may be specified to configure
the client. The following table describes the effect of the different
properties:Property | Description | Required? | Default |
password | Sets the password that the client uses to gain access to the server. | Yes | N/A |
file | Sets a local file to send to the server. | Yes | N/A |
ip | Sets the IP address of the server. | Yes | N/A |
port | Sets the port of the server. | No | 2112 |
TemporaryFileServer
Field Summary | |
---|---|
static int |
COMMAND_ACCOUNTTOSID
|
static int |
COMMAND_SIDTOACCOUNT
|
static int |
COMMAND_TEMPFILE
|
Constructor Summary | |
---|---|
TemporaryFileClient(java.net.InetAddress address,
int iPort,
java.lang.String sPassword,
boolean bSSL)
Constructor. |
|
TemporaryFileClient(java.net.InetAddress address,
int iPort,
java.lang.String sPassword,
java.lang.String sRequestedFilename,
boolean bSSL)
Constructor. |
Method Summary | |
---|---|
void |
close()
Closes the connection to the server, and indicates that the temporary file on the server is no longer in use. |
void |
connect()
Connects to the server. |
void |
connect(int iCommand,
java.lang.String sArgument)
Connects to the server. |
java.lang.String |
dataComplete()
Indicates that all data has been written and gets the filename on the server. |
java.io.InputStream |
getInputStream()
Gets an InputStream to the data on the server. |
static void |
main(java.lang.String[] args)
Main. |
void |
write(byte[] array)
Writes a byte array (flush is performed). |
void |
write(byte[] array,
int iOffset,
int iLength)
Writes a byte array (flush is performed). |
void |
write(java.io.File file)
Writes data from a file. |
void |
write(java.io.InputStream is)
Writes data from an InputStream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int COMMAND_TEMPFILE
public static final int COMMAND_ACCOUNTTOSID
public static final int COMMAND_SIDTOACCOUNT
Constructor Detail |
---|
public TemporaryFileClient(java.net.InetAddress address, int iPort, java.lang.String sPassword, boolean bSSL) throws java.security.NoSuchAlgorithmException, java.io.UnsupportedEncodingException
address
- the IP address of the serveriPort
- the server portsPassword
- the server password
java.security.NoSuchAlgorithmException
- if algorithm not supported
java.io.UnsupportedEncodingException
- if UTF-8 not supportedpublic TemporaryFileClient(java.net.InetAddress address, int iPort, java.lang.String sPassword, java.lang.String sRequestedFilename, boolean bSSL) throws java.security.NoSuchAlgorithmException, java.io.UnsupportedEncodingException
address
- the IP address of the serveriPort
- the server portsPassword
- the server passwordsRequestedFilename
- the filename to request that the server use
java.security.NoSuchAlgorithmException
- if algorithm not supported
java.io.UnsupportedEncodingException
- if UTF-8 not supportedMethod Detail |
---|
public void connect() throws java.io.IOException, java.security.NoSuchAlgorithmException, java.lang.ClassNotFoundException
iCommand
- the command
java.io.IOException
- if an i/o error occurred
java.security.NoSuchAlgorithmException
- if the algorithm does not exist
java.lang.ClassNotFoundException
- if the server sent an invalid
class (should never happen)public void connect(int iCommand, java.lang.String sArgument) throws java.io.IOException, java.security.NoSuchAlgorithmException, java.lang.ClassNotFoundException
iCommand
- the commandsArgument
- argument to the command
java.io.IOException
- if an i/o error occurred
java.security.NoSuchAlgorithmException
- if the algorithm does not exist
java.lang.ClassNotFoundException
- if the server sent an invalid
class (should never happen)public void write(java.io.File file) throws java.io.IOException
file
- the file to write
java.io.IOException
- if an i/o error occurredpublic void write(java.io.InputStream is) throws java.io.IOException
is
- the InputStream to read data from
java.io.IOException
- if an i/o error occurredpublic void write(byte[] array) throws java.io.IOException
array
- the array to write, or null to write no data
java.io.IOException
- if an i/o error occurredpublic void write(byte[] array, int iOffset, int iLength) throws java.io.IOException
array
- the array to write, or null to write no dataiOffset
- the offset in the array to write fromiLength
- the number of bytes to write
java.io.IOException
- if an i/o error occurredpublic java.lang.String dataComplete() throws java.io.IOException
java.io.IOException
- if an i/o error occurred, or the server command
failed for some other reasonpublic java.io.InputStream getInputStream() throws java.io.IOException
InputStream
to the data on the server. This method may
be called after dataComplete
to get the data from the server.
However, when the InputStream
is closed the connection to the
server is closed, so close
must be called.
InputStream
to the data
java.io.IOException
- if an i/o error occurredpublic void close()
public static void main(java.lang.String[] args)
args
- command line arguments
|
Oracle | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |