FileNotFoundException saving Html on outputstream

Hello,
I have a problem executing as unit test a functionality that exports an excel area as HTML.
I save HTML in a ByteArrayOutputStream, but it uses anyway a sort of cache on filesystem, on my PC it uses my windows temp.
The problem occurs when I execute test on continuous integration system, where I have not a temporary writable filesystem folder.

java.io.FileNotFoundException: /tmp_files_files/sheet001.htm (No such file or directory)

Code is more or less this.


  private static final String AREAHTML = "HTML";
  @Test
  void getAreaAsHtmlTestB() throws Exception {
    Workbook workbook = new Workbook(this.getClass().getResourceAsStream("/xlsx/ImagesAndChartsRendering.xlsx"));
    WorksheetCollection worksheets = workbook.getWorksheets();
    Range range = worksheets.getRangeByName(AREAHTML);
    if (Objects.isNull(range) && AREAHTML.contains("!")) {
      range = worksheets.getRangeByName(AREAHTML.split("!")[1]);
    }
    range.getWorksheet().getPageSetup().setPrintArea(range.getAddress());

    HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML);
    options.setExportPrintAreaOnly(true);
    options.setExportBogusRowData(false);

    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    workbook.save(byteArrayOutputStream, options);
    String html = byteArrayOutputStream.toString(StandardCharsets.UTF_8);

    Assertions.assertNotNull(html);
  }

Is it possible to avoid using temporary folder if I’m saving in an output stream?
otherwise how can I set this folder by code and not system properties?
Thanks

@federico.mameli,

I think you may try to use/specify HtmlSaveOptions.setAttachedFilesDirectory to set your desired folder which will contain the resource files including images temporarily.

If I specify a path it works, and for the moment I can find a way to overcome the problem, but…

I discovered that it normally uses the system property java.io.tmpdir and attaches “_files_files” to it.
If java.io.tmpdir is “/tmp/” the result is “/tmp/_files_files” that under linux can work
If java.io.tmpdir is “/tmp” the result is “/tmp_files_files” that under linux can’t work

That is interesting behavior on linux. So, you can change the temp directory to set it “/tmp/” to make it work accordingly.