'java.lang.ClassNotFoundException: org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream on using HSSFWorkbook
I'm trying to implement reading from .xls file. I have the following code:
FileInputStream file = null;
Workbook workbook = null;
try {
file = new FileInputStream(System.getProperty("user.home") + "/Downloads/" + fileName);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
if (fileName.endsWith(".xls")) {
try {
**workbook = new HSSFWorkbook(file);**
} catch (IOException e) {
e.printStackTrace();
}
This marked code line crashes.
I imported in pom.xml:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.0</version>
</dependency>
but I got the error: Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream
I would appreciate help on this. Thanks.
Solution 1:[1]
Add
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
to you pom
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Saurabh Jhunjhunwala |
