Package javax0.license3j.io
Class LicenseWriter
- java.lang.Object
-
- javax0.license3j.io.LicenseWriter
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class LicenseWriter extends Object implements Closeable
Write the license into the output. Use the constructors to create a writer object specifying the target for the license, and then use one of the 'write()' methods to perform writing specifying the format. The writing, being atomic in the sense that there is no possible way or reason to write anything more into the destination, closes the output. Nevertheless, the class contains aclose()
method that can be called.The class also implements the
Closeable
interface, thus it can be used in try-with-resources block to call theclose()
method.
-
-
Constructor Summary
Constructors Constructor Description LicenseWriter(File file)
LicenseWriter(OutputStream os)
LicenseWriter(String fileName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
write(License license)
Write the license to the output in binary format.void
write(License license, IOFormat format)
Write the license into the output and close the output.
-
-
-
Constructor Detail
-
LicenseWriter
public LicenseWriter(OutputStream os)
-
LicenseWriter
public LicenseWriter(File file) throws FileNotFoundException
- Throws:
FileNotFoundException
-
LicenseWriter
public LicenseWriter(String fileName) throws FileNotFoundException
- Throws:
FileNotFoundException
-
-
Method Detail
-
write
public void write(License license, IOFormat format) throws IOException
Write the license into the output and close the output.- Parameters:
license
- the license itselfformat
- the desired format of the license, can beIOFormat.STRING
,IOFormat.BASE64
orIOFormat.BINARY
- Throws:
IOException
- if the output cannot be written
-
write
public void write(License license) throws IOException
Write the license to the output in binary format.- Parameters:
license
- to write to the file- Throws:
IOException
- if the output cannot be written
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-