File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
commons/src/main/java/com/itextpdf/commons/utils Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,21 @@ public static boolean fileExists(String path) {
110
110
return false ;
111
111
}
112
112
113
+ /**
114
+ * Checks whether is provided file not empty.
115
+ *
116
+ * @param path the path to the file to be checked on emptiness
117
+ *
118
+ * @return {@code true} if such file is not empty, {@code false} otherwise
119
+ */
120
+ public static boolean isFileNotEmpty (String path ) {
121
+ if (path != null ) {
122
+ File f = new File (path );
123
+ return f .exists () && f .isFile () && f .length () > 0 ;
124
+ }
125
+ return false ;
126
+ }
127
+
113
128
/**
114
129
* Checks whether there is a directory at the provided path.
115
130
*
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ public ZipFileWriter(String archivePath) throws IOException {
51
51
if (archivePath == null ) {
52
52
throw new IOException (CommonsExceptionMessageConstant .FILE_NAME_CAN_NOT_BE_NULL );
53
53
}
54
- if (FileUtil .fileExists (archivePath ) || FileUtil .directoryExists (archivePath )) {
54
+ if (FileUtil .isFileNotEmpty (archivePath ) || FileUtil .directoryExists (archivePath )) {
55
55
throw new IOException (
56
56
MessageFormatUtil .format (CommonsExceptionMessageConstant .FILE_NAME_ALREADY_EXIST , archivePath ));
57
57
}
You can’t perform that action at this time.
0 commit comments