Skip to content

Commit

Permalink
revert to "new FileInputStream(...)" instead of Files.newInputStream(…
Browse files Browse the repository at this point in the history
……) (#34)

* revert to "new FileInputStream(...)" instead of Files.newInputStream(...)

* add todo, clean up
  • Loading branch information
spoltier authored Feb 27, 2024
1 parent 545829d commit da76e69
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/com/miraisolutions/xlconnect/Workbook.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.poi.xssf.usermodel.*;

import java.io.*;
import java.nio.file.Files;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -101,8 +100,9 @@ private Workbook(File excelFile, String password) throws IOException {
/*
* NOTE: We are using a FileInputStream since otherwise using 'save' multiple times would cause
* a JVM crash as described here: https://bz.apache.org/bugzilla/show_bug.cgi?id=53515
* TODO once we no longer support java 8, try again to switch to Files.newInputStream(excelFile.toPath())
*/
this.workbook = WorkbookFactory.create(Files.newInputStream(excelFile.toPath()), password);
this.workbook = WorkbookFactory.create(new FileInputStream(excelFile), password);
this.excelFile = excelFile;
init();
}
Expand All @@ -111,8 +111,9 @@ private Workbook(File excelFile) throws IOException {
/*
* NOTE: We are using a FileInputStream since otherwise using 'save' multiple times would cause
* a JVM crash as described here: https://bz.apache.org/bugzilla/show_bug.cgi?id=53515
* TODO once we no longer support java 8, try again to switch to Files.newInputStream(excelFile.toPath())
*/
this.workbook = WorkbookFactory.create(Files.newInputStream(excelFile.toPath()));
this.workbook = WorkbookFactory.create(new FileInputStream(excelFile));
this.excelFile = excelFile;
init();
}
Expand Down Expand Up @@ -727,7 +728,8 @@ public void addImage(File imageFile, String name, boolean originalSize) throws I
CellReference bottomRight = aref.getLastCell();

int imageType = getImageType(imageFile);
InputStream is = Files.newInputStream(imageFile.toPath());
// TODO once we no longer support java 8, try again to switch to Files.newInputStream(imageFile.toPath())
InputStream is = new FileInputStream(imageFile);
byte[] bytes = IOUtils.toByteArray(is);
int imageIndex = workbook.addPicture(bytes, imageType);
is.close();
Expand Down

0 comments on commit da76e69

Please sign in to comment.