Package javax0.license3j.io
Class LicenseReader
- java.lang.Object
-
- javax0.license3j.io.LicenseReader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class LicenseReader extends Object implements Closeable
Reads a license from some input.
-
-
Constructor Summary
Constructors Constructor Description LicenseReader(File file)
Create a new license reader that will read the license from the file.LicenseReader(File file, long limit)
Create a new license reader that will read the license from the file.LicenseReader(InputStream is)
Create a new license reader that will read the license from the input stream.LicenseReader(String fileName)
Create a new license reader that will read the license from the file named.LicenseReader(String fileName, long limit)
Create a new license reader that will read the license from the file named.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
License
read()
Read the license from the input assuming the license is binary formatted.License
read(IOFormat format)
Read the license from the input assuming that the format of the license on the input has the format specified by the argument.
-
-
-
Constructor Detail
-
LicenseReader
public LicenseReader(InputStream is)
Create a new license reader that will read the license from the input stream. Note that using this version of LicenseReader does not provide any protection against enormously and erroneously large input. The caller has to make sure the source of the input stream is really a license file and that it is not too large for the application with the actual memory settings.- Parameters:
is
- the input stream from which the license is to be read
-
LicenseReader
public LicenseReader(File file, long limit) throws FileNotFoundException
Create a new license reader that will read the license from the file. If the size of the file is larger than the given limit then this constructor will throw illegal argument exception.- Parameters:
file
- the file that contains the licenselimit
- the maximum number of bytes of the license that the program can handle- Throws:
FileNotFoundException
- if the file cannot be found
-
LicenseReader
public LicenseReader(File file) throws FileNotFoundException
Create a new license reader that will read the license from the file. This constructor simply opens an input stream from the file and callsLicenseReader(InputStream)
. See the notes there about the size limits.- Parameters:
file
- the file that contains the license- Throws:
FileNotFoundException
- if the file cannot be found
-
LicenseReader
public LicenseReader(String fileName, long limit) throws FileNotFoundException
Create a new license reader that will read the license from the file named. This constructor simply opens an input stream from the file and callsLicenseReader(File, long)
. See the notes there about the size limits.- Parameters:
fileName
- the name of the filelimit
- the maximum number of bytes of the license that the program can handle- Throws:
FileNotFoundException
- if the file cannot be found
-
LicenseReader
public LicenseReader(String fileName) throws FileNotFoundException
Create a new license reader that will read the license from the file named. This constructor simply opens an input stream from the file and callsLicenseReader(File)
. See the notes there about the size limits.- Parameters:
fileName
- the name of the file- Throws:
FileNotFoundException
- if the file cannot be found
-
-
Method Detail
-
read
public License read() throws IOException
Read the license from the input assuming the license is binary formatted.- Returns:
- the license created from the file
- Throws:
IOException
- when the file cannot be read
-
read
public License read(IOFormat format) throws IOException
Read the license from the input assuming that the format of the license on the input has the format specified by the argument.- Parameters:
format
- the assumed format of the license, can beIOFormat.STRING
,IOFormat.BASE64
orIOFormat.BINARY
- Returns:
- the license
- Throws:
IOException
- if the input cannot be read
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-