EDU.bmrb.net
Class BmrbFileGetSend

java.lang.Object
  |
  +--EDU.bmrb.net.BmrbFileGetSend

public class BmrbFileGetSend
extends java.lang.Object


Field Summary
protected  java.net.URL cgiURL
           
 
Constructor Summary
BmrbFileGetSend(java.net.URL docBase)
          Constructor: Creates the URL for the file_get_send CGI program, by using this applets' document base string.
 
Method Summary
 void delFile(java.lang.String remoteFName)
          This method deletes the specified file from the host
 byte[] getFile(java.lang.String remoteFName)
          This method gets the specified file, and generates a new String containing the contents of the file.
 void sendFile(java.lang.String remoteFName, byte[] fileContents)
          This method sends the file's contents from a string variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cgiURL

protected java.net.URL cgiURL
Constructor Detail

BmrbFileGetSend

public BmrbFileGetSend(java.net.URL docBase)
                throws java.net.MalformedURLException,
                       java.io.IOException
Constructor: Creates the URL for the file_get_send CGI program, by using this applets' document base string. If you call this constructor from within an applet, you can use the applet's getDocumentBase() method to retrieve this URL.
Parameters:
docBase - the URL of the applet's documentation page in which this is being run.
Throws:
java.net.MalformedURLException - thrown if the URL docBase string is not valid URL syntax.
Method Detail

sendFile

public void sendFile(java.lang.String remoteFName,
                     byte[] fileContents)
              throws java.io.IOException,
                     HTTPException
This method sends the file's contents from a string variable. An example of using it is:
     bmrbFileGetSend handle = [...snip...];
     [...snip...]
     handle.sendFile( "filename.txt",
                      "This is\nThe file's\nContents.\n" );
 
Parameters:
remoteFName - The name of the file to be stored on the host. Be sure to keep it unique.
fileContents - The contents of the file to send to the host.
Throws:
java.io.IOException - thrown by a number of possible I/O errors.
HTTPException - if the HTTP response from the server was anything other than "200 OK", this is thrown and the status string is in "getMessage()".

getFile

public byte[] getFile(java.lang.String remoteFName)
               throws java.io.IOException,
                      HTTPException
This method gets the specified file, and generates a new String containing the contents of the file.

Parameters:
remoteFName - the name of the file to be retrieved from the host.
Returns:
A new byte array containing the contents of the file.
Throws:
java.io.IOException - thrown if there are any I/O errors.
HTTPException - if the HTTP response from the server was anything other than "200 OK", this is thrown and the status string is in "getMessage()".

delFile

public void delFile(java.lang.String remoteFName)
             throws java.io.IOException,
                    HTTPException
This method deletes the specified file from the host
Parameters:
remoteFName - the name of the file to be removed from the host.
Throws:
IOExcpetion - when some I/O error happened in the traffic.
HTTPException - when the "HTTP/1.0 XXX ..." string returned indicates some error. The getMessage() field of the exception contains the errror message returned.