Browse Source

Update Javadocs to refer to the fact that WorkbookFactory.create will throw a EncryptedDocumentException if the file is password protected

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1662074 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_12_FINAL
Nick Burch 9 years ago
parent
commit
51209bc957
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java

+ 5
- 2
src/ooxml/java/org/apache/poi/ss/usermodel/WorkbookFactory.java View File

import java.io.InputStream; import java.io.InputStream;
import java.io.PushbackInputStream; import java.io.PushbackInputStream;


import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.POIXMLDocument; import org.apache.poi.POIXMLDocument;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
* than using a {@link File}.</p> * than using a {@link File}.</p>
* <p>Note that in order to properly release resources the * <p>Note that in order to properly release resources the
* Workbook should be closed after use. * Workbook should be closed after use.
* @throws EncryptedDocumentException If the workbook given is password protected
*/ */
public static Workbook create(InputStream inp) throws IOException, InvalidFormatException {
public static Workbook create(InputStream inp) throws IOException, InvalidFormatException, EncryptedDocumentException {
// If clearly doesn't do mark/reset, wrap up // If clearly doesn't do mark/reset, wrap up
if (! inp.markSupported()) { if (! inp.markSupported()) {
inp = new PushbackInputStream(inp, 8); inp = new PushbackInputStream(inp, 8);
* the given File, which must exist and be readable. * the given File, which must exist and be readable.
* <p>Note that in order to properly release resources the * <p>Note that in order to properly release resources the
* Workbook should be closed after use. * Workbook should be closed after use.
* @throws EncryptedDocumentException If the workbook given is password protected
*/ */
public static Workbook create(File file) throws IOException, InvalidFormatException {
public static Workbook create(File file) throws IOException, InvalidFormatException, EncryptedDocumentException {
if (! file.exists()) { if (! file.exists()) {
throw new FileNotFoundException(file.toString()); throw new FileNotFoundException(file.toString());
} }

Loading…
Cancel
Save