mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
remove deprecated hasOOXMLHeader method (#941)
This commit is contained in:
parent
9fb2c4b03e
commit
540f0e5617
@ -54,10 +54,6 @@ class TestDetectAsOOXML {
|
||||
void testDetectAsPOIFS(String file, FileMagic fm) throws IOException {
|
||||
try (InputStream is = FileMagic.prepareToCheckMagic(openSampleFileStream(file))) {
|
||||
FileMagic act = FileMagic.valueOf(is);
|
||||
|
||||
assertEquals(act == FileMagic.OOXML, DocumentFactoryHelper.hasOOXMLHeader(is),
|
||||
"OOXML files should be detected, others not");
|
||||
|
||||
assertEquals(fm, act, "file magic failed for " + file);
|
||||
}
|
||||
}
|
||||
@ -70,7 +66,7 @@ class TestDetectAsOOXML {
|
||||
InputStream is = FileMagic.prepareToCheckMagic(testInput);
|
||||
|
||||
// detect header
|
||||
assertFalse(DocumentFactoryHelper.hasOOXMLHeader(is));
|
||||
assertFalse(FileMagic.valueOf(is) == FileMagic.OOXML);
|
||||
|
||||
// check if InputStream is still intact
|
||||
byte[] act = IOUtils.toByteArray(is);
|
||||
|
||||
@ -28,7 +28,6 @@ import org.apache.poi.EncryptedDocumentException;
|
||||
import org.apache.poi.poifs.crypt.Decryptor;
|
||||
import org.apache.poi.poifs.crypt.EncryptionInfo;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.Removal;
|
||||
|
||||
/**
|
||||
* A small base class for the various factories, e.g. WorkbookFactory,
|
||||
@ -100,22 +99,4 @@ public final class DocumentFactoryHelper {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the supplied InputStream (which MUST
|
||||
* support mark and reset) has a OOXML (zip) header at the start of it.<p>
|
||||
*
|
||||
* If unsure if your InputStream does support mark / reset,
|
||||
* use {@link FileMagic#prepareToCheckMagic(InputStream)} to wrap it and make
|
||||
* sure to always use that, and not the original!
|
||||
*
|
||||
* @param inp An InputStream which supports either mark/reset
|
||||
*
|
||||
* @deprecated in 3.17-beta2, use {@link FileMagic#valueOf(InputStream)} == FileMagic.OOXML instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Removal(version="4.0")
|
||||
public static boolean hasOOXMLHeader(InputStream inp) throws IOException {
|
||||
return FileMagic.valueOf(inp) == FileMagic.OOXML;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user