mirror of https://github.com/apache/poi.git
Include file-name in EmptyFileException
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885192 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7aa6b06085
commit
eba33ddb6f
|
@ -16,6 +16,8 @@
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
package org.apache.poi;
|
package org.apache.poi;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown if an Empty (zero byte) file is supplied
|
* Exception thrown if an Empty (zero byte) file is supplied
|
||||||
*/
|
*/
|
||||||
|
@ -25,4 +27,8 @@ public class EmptyFileException extends IllegalArgumentException {
|
||||||
public EmptyFileException() {
|
public EmptyFileException() {
|
||||||
super("The supplied file was empty (zero bytes long)");
|
super("The supplied file was empty (zero bytes long)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EmptyFileException(File file) {
|
||||||
|
super("The supplied file '" + file.getAbsolutePath() + "' was empty (zero bytes long)");
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -181,7 +181,7 @@ public final class ExtractorFactory {
|
||||||
@SuppressWarnings({"java:S2095"})
|
@SuppressWarnings({"java:S2095"})
|
||||||
public static POITextExtractor createExtractor(File file, String password) throws IOException {
|
public static POITextExtractor createExtractor(File file, String password) throws IOException {
|
||||||
if (file.length() == 0) {
|
if (file.length() == 0) {
|
||||||
throw new EmptyFileException();
|
throw new EmptyFileException(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
final FileMagic fm = FileMagic.valueOf(file);
|
final FileMagic fm = FileMagic.valueOf(file);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
|
@ -15,8 +14,6 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
|
|
||||||
package org.apache.poi.poifs.filesystem;
|
package org.apache.poi.poifs.filesystem;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -213,7 +210,7 @@ public class POIFSFileSystem extends BlockStore
|
||||||
// Initialize the datasource
|
// Initialize the datasource
|
||||||
if (srcFile != null) {
|
if (srcFile != null) {
|
||||||
if (srcFile.length() == 0)
|
if (srcFile.length() == 0)
|
||||||
throw new EmptyFileException();
|
throw new EmptyFileException(srcFile);
|
||||||
|
|
||||||
FileBackedDataSource d = new FileBackedDataSource(srcFile, readOnly);
|
FileBackedDataSource d = new FileBackedDataSource(srcFile, readOnly);
|
||||||
channel = d.getChannel();
|
channel = d.getChannel();
|
||||||
|
|
|
@ -263,7 +263,7 @@ public final class SlideShowFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.length() == 0) {
|
if (file.length() == 0) {
|
||||||
throw new EmptyFileException();
|
throw new EmptyFileException(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileMagic fm = FileMagic.valueOf(file);
|
FileMagic fm = FileMagic.valueOf(file);
|
||||||
|
|
|
@ -269,7 +269,7 @@ public final class WorkbookFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.length() == 0) {
|
if (file.length() == 0) {
|
||||||
throw new EmptyFileException();
|
throw new EmptyFileException(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileMagic fm = FileMagic.valueOf(file);
|
FileMagic fm = FileMagic.valueOf(file);
|
||||||
|
|
Loading…
Reference in New Issue