Can I reference a file from within a Spring Boot project?

时间:2016-02-03 02:47:07

标签: java spring spring-boot xlsx

I am currently writing a spring boot program that should populate an XLSX template with data and am trying to read the template from inside the project. My directory structure is as follows:

enter image description here

I am now trying to access the file using the following code:

try {
        InputStream fis = this.getClass().getResourceAsStream("xlstemplates/billingReview.xlsx");
        XSSFWorkbook billingReviewTemplate = new XSSFWorkbook(fis);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

Unfortunately I have yet to find a way to read the xlsx file into an InputStream. It always comes back null. Anyone have any pointers on how I can reference that file that is included in the project?

0 个答案:

没有答案