Class KeyGenerator.ToFileThread
java.lang.Object
|
+--KeyGenerator.ToFileThread
- All Implemented Interfaces:
- java.lang.Runnable
- Enclosing class:
- KeyGenerator
- public class KeyGenerator.ToFileThread
- extends java.lang.Object
- implements java.lang.Runnable
This inner class can be used by programs wich wants a
progessbars, or wants to run the process as a thread
The Thread version must be used like this:
KeyGenerator outerClass = new KeyGenerator();
KeyGenerator.ToFileThread keyGenerator = null;
keyGenerator = outerClass. new ToFileThread();
keyGenerator.toFile(fileName, keyLength);
Thread generateKey = new Thread(keyGenerator);
generateKey.start();
Then the program may access the percentComplete field
Field Summary |
int |
percentComplete
Percent complete, for use with progressbars/etc.. |
Constructor Summary |
KeyGenerator.ToFileThread()
Initializes the KeyGenerator using SUN's SHA1PRNG algorithm |
KeyGenerator.ToFileThread(java.lang.String algorithm,
java.lang.String provider)
Initializes the KeyGenerator using specified provider and
algorithm |
Method Summary |
void |
run()
This method will be run by Thread.start() and takes care of
the actual key generating proces |
void |
toFile(java.io.File file,
int keyLength)
This method sets the filename and keylength
and MUST be called before Thread.start() |
void |
toFile(java.lang.String fileName,
int keyLength)
This method sets the filename and keylength
and MUST be called before Thread.start() |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
percentComplete
public int percentComplete
- Percent complete, for use with progressbars/etc..
KeyGenerator.ToFileThread
public KeyGenerator.ToFileThread()
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException
- Initializes the KeyGenerator using SUN's SHA1PRNG algorithm
- Parameters:
none
- - Throws:
java.security.NoSuchAlgorithmException
- If algorithm is not foundjava.security.NoSuchProviderException
- If the provieder is not found
KeyGenerator.ToFileThread
public KeyGenerator.ToFileThread(java.lang.String algorithm,
java.lang.String provider)
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException
- Initializes the KeyGenerator using specified provider and
algorithm
- Parameters:
algorithm
- The name of tha algorithm to useprovider
- The name of the provider who provides the
algorithm- Throws:
java.security.NoSuchAlgorithmException
- If algorithm is not foundjava.security.NoSuchProviderException
- If the provieder is not found
toFile
public void toFile(java.lang.String fileName,
int keyLength)
throws java.io.IOException,
java.io.FileNotFoundException
- This method sets the filename and keylength
and MUST be called before Thread.start()
- Parameters:
fileName
- file to write key tokeyLength
- number of bytes to writeShows
- if the method was successful
toFile
public void toFile(java.io.File file,
int keyLength)
throws java.io.IOException,
java.io.FileNotFoundException
- This method sets the filename and keylength
and MUST be called before Thread.start()
- Parameters:
file
- file to write key tokeyLength
- number of bytes to writeShows
- if the method was successful
run
public void run()
- This method will be run by Thread.start() and takes care of
the actual key generating proces
- Specified by:
run
in interface java.lang.Runnable