Package javax0.license3j.io
Class KeyPairWriter
- java.lang.Object
-
- javax0.license3j.io.KeyPairWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class KeyPairWriter extends java.lang.Object implements java.io.Closeable
Class to write the key pair into two files. Key are read individually but they are written in pairs right after they are generated. This class can be used by applications that generate keys and it is used by the repl application. Create an instance of the class using one of the constructors specifying the output files and then invoke thewrite(LicenseKeyPair, IOFormat)
method to save the keys into the files.
-
-
Constructor Summary
Constructors Constructor Description KeyPairWriter(java.io.File priv, java.io.File publ)
KeyPairWriter(java.io.OutputStream osPrivate, java.io.OutputStream osPublic)
KeyPairWriter(java.lang.String priv, java.lang.String publ)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
write(LicenseKeyPair pair, IOFormat format)
Write the key pair into the output files.
-
-
-
Constructor Detail
-
KeyPairWriter
public KeyPairWriter(java.io.OutputStream osPrivate, java.io.OutputStream osPublic)
-
KeyPairWriter
public KeyPairWriter(java.io.File priv, java.io.File publ) throws java.io.FileNotFoundException
- Throws:
java.io.FileNotFoundException
-
KeyPairWriter
public KeyPairWriter(java.lang.String priv, java.lang.String publ) throws java.io.FileNotFoundException
- Throws:
java.io.FileNotFoundException
-
-
Method Detail
-
write
public void write(LicenseKeyPair pair, IOFormat format) throws java.io.IOException
Write the key pair into the output files.- Parameters:
pair
- the key pair to write.format
- that can beIOFormat.BINARY
orIOFormat.BASE64
. UsingIOFormat.STRING
will throw exception as keys, as opposed to licenses, cannot be saved in string format.- Throws:
java.io.IOException
- when the underlying media cannot be written
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-