Exceptions are as follows:
Org, The apache poi. EmptyFileException: The supplied file was empty (zero bytes long)
The at org, apache poi. Util. IOUtils. PeekFirstNBytes (IOUtils. Java: 74)
The at org, apache poi. Util. IOUtils. PeekFirst8Bytes (IOUtils. Java: 57)
The at org, apache poi. Poifs. Filesystem. FileMagic. The valueOf (FileMagic. Java: 135)
The at org, apache poi. Openxml4j. Opc. Internal. ZipHelper. VerifyZipHeader (ZipHelper. Java: 175)
The at org, apache poi. Openxml4j. Opc. Internal. ZipHelper. OpenZipStream (ZipHelper. Java: 209)
The at org, apache poi. Openxml4j. Opc. ZipPackage. & lt; Init> (ZipPackage. Java: 98)
At org, apache poi. Openxml4j. Opc. OPCPackage. Open (324) OPCPackage. Java:
At org, apache poi. Util. PackageHelper. Open (37) PackageHelper. Java:
The at org, apache poi. XWPF. Usermodel. XWPFDocument. & lt; Init> (XWPFDocument. Java: 116)
Don't know how to avoid the abnormal,
How to determine whether a word document content is empty? Or how to get to the size of a document?
CodePudding user response:
Whether the document content is empty:
The File File=new File (" test. Docx ");
If (the file. The length ()==0) {
System. Out.println (" file is empty!" );
}
In addition to read the Word Document content with Free Spire. Doc for Java is a good method, two lines of code Document Document=new Document (" input. Docx "); String text=document. The getText ();
CodePudding user response:
Upstairs said makes sense
CodePudding user response:
Let the poi generate excel, do not generate its own excel empty file, generate excel is not standard cannot be resolved