Pregunta

I need to load an existing docx template and I would like to include the template file inside the jar so there would only be the jar file for the user.

I've tried the following ...

String inputfilepath = (getClass().getResource("/letter.docx")).toString();

WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
            .load(new java.io.File(inputfilepath));

However, I think because .load(File) is expecting a File parameter it cannot load the docx. Is there a way to load the file for WordprocessingMLPackage from the resources folder?

Thanks

¿Fue útil?

Solución

Get the resource as an InputStream, then use WordprocessingMLPackage's:

public static WordprocessingMLPackage load(InputStream is)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top