diff --git a/src/java/org/apache/poi/EmptyFileException.java b/src/java/org/apache/poi/EmptyFileException.java index ddbd142806..07828343be 100644 --- a/src/java/org/apache/poi/EmptyFileException.java +++ b/src/java/org/apache/poi/EmptyFileException.java @@ -16,6 +16,8 @@ ==================================================================== */ package org.apache.poi; +import java.io.File; + /** * Exception thrown if an Empty (zero byte) file is supplied */ @@ -25,4 +27,8 @@ public class EmptyFileException extends IllegalArgumentException { public EmptyFileException() { super("The supplied file was empty (zero bytes long)"); } + + public EmptyFileException(File file) { + super("The supplied file '" + file.getAbsolutePath() + "' was empty (zero bytes long)"); + } } \ No newline at end of file diff --git a/src/java/org/apache/poi/extractor/ExtractorFactory.java b/src/java/org/apache/poi/extractor/ExtractorFactory.java index 4348c67f60..c310715bb2 100644 --- a/src/java/org/apache/poi/extractor/ExtractorFactory.java +++ b/src/java/org/apache/poi/extractor/ExtractorFactory.java @@ -181,7 +181,7 @@ public final class ExtractorFactory { @SuppressWarnings({"java:S2095"}) public static POITextExtractor createExtractor(File file, String password) throws IOException { if (file.length() == 0) { - throw new EmptyFileException(); + throw new EmptyFileException(file); } final FileMagic fm = FileMagic.valueOf(file); diff --git a/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java index 20fc398e27..94c68a6379 100644 --- a/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java +++ b/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java @@ -1,4 +1,3 @@ - /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,8 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - - package org.apache.poi.poifs.filesystem; import java.io.ByteArrayOutputStream; @@ -213,7 +210,7 @@ public class POIFSFileSystem extends BlockStore // Initialize the datasource if (srcFile != null) { if (srcFile.length() == 0) - throw new EmptyFileException(); + throw new EmptyFileException(srcFile); FileBackedDataSource d = new FileBackedDataSource(srcFile, readOnly); channel = d.getChannel(); diff --git a/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java b/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java index cb0607de61..a32123afe5 100644 --- a/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java +++ b/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java @@ -263,7 +263,7 @@ public final class SlideShowFactory { } if (file.length() == 0) { - throw new EmptyFileException(); + throw new EmptyFileException(file); } FileMagic fm = FileMagic.valueOf(file); diff --git a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java index c2b6e6936f..3e9b887179 100644 --- a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java +++ b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java @@ -269,7 +269,7 @@ public final class WorkbookFactory { } if (file.length() == 0) { - throw new EmptyFileException(); + throw new EmptyFileException(file); } FileMagic fm = FileMagic.valueOf(file);