6.3.3 Miscellaneous Helper Class

The temporary directory only exists between a JSM OPEN and JSM CLOSE.

The temporary directory is cleared on the JSM OPEN.

The temporary directory is also cleared on the JSMCLOSE.

When a service thread starts, a call to the JSMManager.clearTemporaryDirectory method is performed to make sure no previous temporary files from a previous thread with the same hash code exist.

Get Temporary Directory

The static method JSMManager.getTemporaryDirectory returns the temporary directory of the current service as a java.io.File object.

The temporary directory is not created by this method.

The name of this temporary directory is the job number and hash code of the service thread.

Example

File directory = JSMManager.getTemporaryDirectory () ;

 

Create Temporary Directory

The static method JSMManager.createTemporaryDirectory returns the temporary directory of the current service as a java.io.File object.

The temporary directory is created by this method.

The name of this temporary directory is the job number and hash code of the service thread.

Example

File directory = JSMManager.createTemporaryDirectory () ;

 

Create Temporary File

The static method JSMManager.createTemporaryFile returns the temporary file as a java.io.File object.

If the temporary directory does not exist then it is created, but the temporary file is not created.

The filename only needs to be unique within the service program, so a simple name like "upload" can be used.

To read and write to the file use the FileInputStream and FileOutputStream classes.

Example

File file = JSMManager.createTemporaryFile ( filename ) ;

 

Clear Temporary Directory and Files

The static method JSMManager.clearTemporaryDirectory deletes all files in the temporary directory and then deletes the temporary directory.

There is no need for the programmer to clear the temporary directory.

Example

boolean ok = JSMManager.clearTemporaryDirectory () ;