Free Support Forum - aspose.com

Cant set the license

Hi,

I try to set the license from my servlet and receive error: It seems that there is no such mwthod named setLicense will take string as paramener. Please help. Urgent !!

java:86: cannot find symbol
symbol : method setLicense(java.lang.String)
location: class com.aspose.cells.License
license.setLicense("c:\\spose.Cells.lic");

and I find fopllowing code from web. what should I use for charset 1 and charsey 2 ?

File file = new File("..."); //license file
byte[] buffer = new byte[(int)file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(buffer);
fis.close();
String xml = new String(buffer, charset1);
buffer = xml.getBytes(charset2);
ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
new License().setLicense(bais);

Hi,


You may use the overloaded method i.e.:
setLicense(java.io.InputStream stream)
The usage of license file is to build one InputStream(such as FileInputStream) and pass the InputStream to License.setLicense() method. So the license file can be put into any place at your web application where you can access it in the same way as common file.

e.g
com.aspose.cells.License lic = new com.aspose.cells.License();
lic.setLicense(new FileInputStream(stringLicenseFilePath));