From 78596d7891bfb8a524fe9991c2ab3b3e6d66a2ad Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 9 Dec 2020 17:35:29 +0000 Subject: [PATCH] remove more deprecated code git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1884262 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ddf/AbstractEscherOptRecord.java | 10 -- .../apache/poi/ddf/EscherArrayProperty.java | 18 --- .../apache/poi/ddf/EscherComplexProperty.java | 35 ----- .../poi/hssf/record/CalcCountRecord.java | 11 -- .../poi/hssf/record/CalcModeRecord.java | 11 -- .../apache/poi/hssf/record/GridsetRecord.java | 11 -- .../poi/hssf/record/GroupMarkerSubRecord.java | 11 -- .../record/HorizontalPageBreakRecord.java | 13 -- .../apache/poi/hssf/record/LabelRecord.java | 15 +- .../poi/hssf/record/LbsDataSubRecord.java | 11 -- .../hssf/record/NoteStructureSubRecord.java | 11 -- .../org/apache/poi/hssf/record/ObjRecord.java | 11 -- .../apache/poi/hssf/record/PaneRecord.java | 11 -- .../poi/hssf/record/PrintHeadersRecord.java | 11 -- .../poi/hssf/record/PrintSetupRecord.java | 11 -- .../poi/hssf/record/RightMarginRecord.java | 11 -- .../apache/poi/hssf/record/StringRecord.java | 11 -- .../poi/hssf/record/TextObjectRecord.java | 12 -- .../hssf/record/VerticalPageBreakRecord.java | 13 -- src/java/org/apache/poi/util/IOUtils.java | 134 ------------------ 20 files changed, 1 insertion(+), 381 deletions(-) diff --git a/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java b/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java index dd98cc11e0..1fdf63380e 100644 --- a/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java +++ b/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java @@ -24,7 +24,6 @@ import java.util.function.Supplier; import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.LittleEndian; -import org.apache.poi.util.Removal; /** * Common abstract class for {@link EscherOptRecord} and @@ -153,15 +152,6 @@ public abstract class AbstractEscherOptRecord extends EscherRecord { sortProperties(); } - /** - * @deprecated use {@link #removeEscherProperty(EscherPropertyTypes)} instead - */ - @Deprecated - @Removal(version = "5.0.0") - public void removeEscherProperty(int num){ - properties.removeIf(prop -> prop.getPropertyNumber() == num); - } - public void removeEscherProperty(EscherPropertyTypes type){ properties.removeIf(prop -> prop.getPropertyNumber() == type.propNumber); } diff --git a/src/java/org/apache/poi/ddf/EscherArrayProperty.java b/src/java/org/apache/poi/ddf/EscherArrayProperty.java index c1ac06b7bc..f2c555496e 100644 --- a/src/java/org/apache/poi/ddf/EscherArrayProperty.java +++ b/src/java/org/apache/poi/ddf/EscherArrayProperty.java @@ -54,24 +54,6 @@ public final class EscherArrayProperty extends EscherComplexProperty implements */ private final boolean emptyComplexPart; - /** - * Create an instance of an escher array property. - * This constructor defaults to a 6 bytes header if the complexData is null or byte[0]. - * - * @param id The id consists of the property number, a flag indicating whether this is a blip id and a flag - * indicating that this is a complex property. - * @param complexData The value of this property. - * - * @deprecated use {@link #EscherArrayProperty(EscherPropertyTypes, boolean, int)} and {@link #setComplexData(byte[])} - */ - @Deprecated - @Removal(version = "5.0.0") - @Internal - public EscherArrayProperty(short id, byte[] complexData) { - this(id, safeSize(complexData == null ? 0 : complexData.length)); - setComplexData(complexData); - } - /** * Create an instance of an escher array property. * This constructor can be used to create emptyComplexParts with a complexSize = 0. diff --git a/src/java/org/apache/poi/ddf/EscherComplexProperty.java b/src/java/org/apache/poi/ddf/EscherComplexProperty.java index fc8e75b978..1f33cd735a 100644 --- a/src/java/org/apache/poi/ddf/EscherComplexProperty.java +++ b/src/java/org/apache/poi/ddf/EscherComplexProperty.java @@ -24,7 +24,6 @@ import java.util.function.Supplier; import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.IOUtils; import org.apache.poi.util.LittleEndian; -import org.apache.poi.util.Removal; /** * A complex property differs from a simple property in that the data can not fit inside a 32 bit @@ -37,40 +36,6 @@ public class EscherComplexProperty extends EscherProperty { private byte[] complexData; - /** - * Create a complex property using the property id and a byte array containing the complex - * data value. - * - * @param id The id consists of the property number, a flag indicating whether this is a blip id and a flag - * indicating that this is a complex property. - * @param complexData The value of this property. - * - * @deprecated use {@link #EscherComplexProperty(short, int)} and {@link #setComplexData(byte[])} instead - */ - @Deprecated - @Removal(version = "5.0.0") - public EscherComplexProperty(short id, byte[] complexData) { - this(id, complexData == null ? 0 : complexData.length); - setComplexData(complexData); - } - - /** - * Create a complex property using the property number, a flag to indicate whether this is a - * blip reference and the complex property data. - * - * @param propertyNumber The property number - * @param isBlipId Whether this is a blip id. Should be false. - * @param complexData The value of this complex property. - * - * @deprecated use {@link #EscherComplexProperty(EscherPropertyTypes, boolean, int)} and {@link #setComplexData(byte[])} instead - */ - @Deprecated - @Removal(version = "5.0.0") - public EscherComplexProperty(short propertyNumber, boolean isBlipId, byte[] complexData) { - this(propertyNumber, isBlipId, complexData == null ? 0 : complexData.length); - setComplexData(complexData); - } - /** * Create a complex property using the property id and a byte array containing the complex * data value size. diff --git a/src/java/org/apache/poi/hssf/record/CalcCountRecord.java b/src/java/org/apache/poi/hssf/record/CalcCountRecord.java index 4f865ecf42..3fec4a9b43 100644 --- a/src/java/org/apache/poi/hssf/record/CalcCountRecord.java +++ b/src/java/org/apache/poi/hssf/record/CalcCountRecord.java @@ -24,7 +24,6 @@ import java.util.function.Supplier; import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.LittleEndianOutput; -import org.apache.poi.util.Removal; /** * Specifies the maximum times the gui should perform a formula recalculation. @@ -86,16 +85,6 @@ public final class CalcCountRecord extends StandardRecord { return sid; } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public CalcCountRecord clone() { - return copy(); - } - @Override public CalcCountRecord copy() { return new CalcCountRecord(this); diff --git a/src/java/org/apache/poi/hssf/record/CalcModeRecord.java b/src/java/org/apache/poi/hssf/record/CalcModeRecord.java index 1dd6f93cd0..1cac3134ac 100644 --- a/src/java/org/apache/poi/hssf/record/CalcModeRecord.java +++ b/src/java/org/apache/poi/hssf/record/CalcModeRecord.java @@ -24,7 +24,6 @@ import java.util.function.Supplier; import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.LittleEndianOutput; -import org.apache.poi.util.Removal; /** * Tells the gui whether to calculate formulas automatically, manually or automatically except for tables. @@ -101,16 +100,6 @@ public final class CalcModeRecord extends StandardRecord { return sid; } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public CalcModeRecord clone() { - return copy(); - } - @Override public CalcModeRecord copy() { return new CalcModeRecord(this); diff --git a/src/java/org/apache/poi/hssf/record/GridsetRecord.java b/src/java/org/apache/poi/hssf/record/GridsetRecord.java index a7f050b2aa..d5f705071f 100644 --- a/src/java/org/apache/poi/hssf/record/GridsetRecord.java +++ b/src/java/org/apache/poi/hssf/record/GridsetRecord.java @@ -22,7 +22,6 @@ import java.util.function.Supplier; import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.LittleEndianOutput; -import org.apache.poi.util.Removal; /** * Flag denoting whether the user specified that gridlines are used when printing. @@ -80,16 +79,6 @@ public final class GridsetRecord extends StandardRecord { return sid; } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public GridsetRecord clone() { - return copy(); - } - @Override public GridsetRecord copy() { return new GridsetRecord(this); diff --git a/src/java/org/apache/poi/hssf/record/GroupMarkerSubRecord.java b/src/java/org/apache/poi/hssf/record/GroupMarkerSubRecord.java index d7fe77df86..805bca3442 100644 --- a/src/java/org/apache/poi/hssf/record/GroupMarkerSubRecord.java +++ b/src/java/org/apache/poi/hssf/record/GroupMarkerSubRecord.java @@ -24,7 +24,6 @@ import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.IOUtils; import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianOutput; -import org.apache.poi.util.Removal; /** * ftGmo (0x0006)

@@ -75,16 +74,6 @@ public final class GroupMarkerSubRecord extends SubRecord { return sid; } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings("squid:S2975") - @Deprecated - @Removal(version = "5.0.0") - public GroupMarkerSubRecord clone() { - return copy(); - } - @Override public GroupMarkerSubRecord copy() { return new GroupMarkerSubRecord(this); diff --git a/src/java/org/apache/poi/hssf/record/HorizontalPageBreakRecord.java b/src/java/org/apache/poi/hssf/record/HorizontalPageBreakRecord.java index 328239d6ca..67b16b3d0b 100644 --- a/src/java/org/apache/poi/hssf/record/HorizontalPageBreakRecord.java +++ b/src/java/org/apache/poi/hssf/record/HorizontalPageBreakRecord.java @@ -17,8 +17,6 @@ package org.apache.poi.hssf.record; -import org.apache.poi.util.Removal; - /** * HorizontalPageBreak (0x001B) record that stores page breaks at rows * @@ -48,17 +46,6 @@ public final class HorizontalPageBreakRecord extends PageBreakRecord { return sid; } - /** - * @deprecated use {@link #copy()} instead - */ - @Override - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public PageBreakRecord clone() { - return copy(); - } - @Override public HorizontalPageBreakRecord copy() { return new HorizontalPageBreakRecord(this); diff --git a/src/java/org/apache/poi/hssf/record/LabelRecord.java b/src/java/org/apache/poi/hssf/record/LabelRecord.java index d6b1d031ae..9683c86e4c 100644 --- a/src/java/org/apache/poi/hssf/record/LabelRecord.java +++ b/src/java/org/apache/poi/hssf/record/LabelRecord.java @@ -25,7 +25,6 @@ import org.apache.poi.util.HexDump; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; import org.apache.poi.util.RecordFormatException; -import org.apache.poi.util.Removal; /** * Label Record (0x0204) - read only support for strings stored directly in the cell... @@ -173,19 +172,7 @@ public final class LabelRecord extends Record implements CellValueRecordInterfac * no op! */ @Override - public void setXFIndex(short xf) - { - } - - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public LabelRecord clone() { - return copy(); - } + public void setXFIndex(short xf) {} @Override public LabelRecord copy() { diff --git a/src/java/org/apache/poi/hssf/record/LbsDataSubRecord.java b/src/java/org/apache/poi/hssf/record/LbsDataSubRecord.java index 3838f76bd2..cf06408b3f 100644 --- a/src/java/org/apache/poi/hssf/record/LbsDataSubRecord.java +++ b/src/java/org/apache/poi/hssf/record/LbsDataSubRecord.java @@ -29,7 +29,6 @@ import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianOutput; import org.apache.poi.util.RecordFormatException; -import org.apache.poi.util.Removal; import org.apache.poi.util.StringUtil; /** @@ -281,16 +280,6 @@ public class LbsDataSubRecord extends SubRecord { } } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings("squid:S2975") - @Deprecated - @Removal(version = "5.0.0") - public LbsDataSubRecord clone() { - return copy(); - } - @Override public LbsDataSubRecord copy() { return new LbsDataSubRecord(this); diff --git a/src/java/org/apache/poi/hssf/record/NoteStructureSubRecord.java b/src/java/org/apache/poi/hssf/record/NoteStructureSubRecord.java index 85c553792e..3adff3856d 100644 --- a/src/java/org/apache/poi/hssf/record/NoteStructureSubRecord.java +++ b/src/java/org/apache/poi/hssf/record/NoteStructureSubRecord.java @@ -25,7 +25,6 @@ import org.apache.poi.util.IOUtils; import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianOutput; import org.apache.poi.util.RecordFormatException; -import org.apache.poi.util.Removal; /** * ftNts (0x000D)

@@ -99,16 +98,6 @@ public final class NoteStructureSubRecord extends SubRecord { return sid; } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings("squid:S2975") - @Deprecated - @Removal(version = "5.0.0") - public NoteStructureSubRecord clone() { - return copy(); - } - @Override public NoteStructureSubRecord copy() { return new NoteStructureSubRecord(this); diff --git a/src/java/org/apache/poi/hssf/record/ObjRecord.java b/src/java/org/apache/poi/hssf/record/ObjRecord.java index 2efd1bfa22..beea8ac7e8 100644 --- a/src/java/org/apache/poi/hssf/record/ObjRecord.java +++ b/src/java/org/apache/poi/hssf/record/ObjRecord.java @@ -29,7 +29,6 @@ import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndianByteArrayInputStream; import org.apache.poi.util.LittleEndianByteArrayOutputStream; import org.apache.poi.util.RecordFormatException; -import org.apache.poi.util.Removal; /** * OBJRECORD (0x005D)

@@ -215,16 +214,6 @@ public final class ObjRecord extends Record { return subrecords.add(o); } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public ObjRecord clone() { - return copy(); - } - @Override public ObjRecord copy() { return new ObjRecord(this); diff --git a/src/java/org/apache/poi/hssf/record/PaneRecord.java b/src/java/org/apache/poi/hssf/record/PaneRecord.java index 6db2d7a15c..fa38346961 100644 --- a/src/java/org/apache/poi/hssf/record/PaneRecord.java +++ b/src/java/org/apache/poi/hssf/record/PaneRecord.java @@ -25,7 +25,6 @@ import java.util.function.Supplier; import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.LittleEndianOutput; -import org.apache.poi.util.Removal; /** * Describes the frozen and unfrozen panes. @@ -82,16 +81,6 @@ public final class PaneRecord extends StandardRecord { return sid; } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public PaneRecord clone() { - return copy(); - } - @Override public PaneRecord copy() { return new PaneRecord(this); diff --git a/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java b/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java index ec3906f7d3..07752d70d4 100644 --- a/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java +++ b/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java @@ -22,7 +22,6 @@ import java.util.function.Supplier; import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.LittleEndianOutput; -import org.apache.poi.util.Removal; /** * Whether or not to print the row/column headers when you enjoy your spreadsheet in the physical form. @@ -79,16 +78,6 @@ public final class PrintHeadersRecord extends StandardRecord { return sid; } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public PrintHeadersRecord clone() { - return copy(); - } - public PrintHeadersRecord copy() { return new PrintHeadersRecord(this); } diff --git a/src/java/org/apache/poi/hssf/record/PrintSetupRecord.java b/src/java/org/apache/poi/hssf/record/PrintSetupRecord.java index 00ebf2dbb6..d6404e6245 100644 --- a/src/java/org/apache/poi/hssf/record/PrintSetupRecord.java +++ b/src/java/org/apache/poi/hssf/record/PrintSetupRecord.java @@ -28,7 +28,6 @@ import org.apache.poi.ss.usermodel.PrintSetup; import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.LittleEndianOutput; -import org.apache.poi.util.Removal; /** * Stores print setup options -- bogus for HSSF (and marked as such) @@ -316,16 +315,6 @@ public final class PrintSetupRecord extends StandardRecord { return sid; } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public PrintSetupRecord clone() { - return copy(); - } - @Override public PrintSetupRecord copy() { return new PrintSetupRecord(this); diff --git a/src/java/org/apache/poi/hssf/record/RightMarginRecord.java b/src/java/org/apache/poi/hssf/record/RightMarginRecord.java index a19ac0c01c..94fc0645b2 100644 --- a/src/java/org/apache/poi/hssf/record/RightMarginRecord.java +++ b/src/java/org/apache/poi/hssf/record/RightMarginRecord.java @@ -22,7 +22,6 @@ import java.util.function.Supplier; import org.apache.poi.util.GenericRecordUtil; import org.apache.poi.util.LittleEndianOutput; -import org.apache.poi.util.Removal; /** * Record for the right margin. @@ -63,16 +62,6 @@ public final class RightMarginRecord extends StandardRecord implements Margin { public void setMargin( double field_1_margin ) { this.field_1_margin = field_1_margin; } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public RightMarginRecord clone() { - return copy(); - } - public RightMarginRecord copy() { return new RightMarginRecord(this); } diff --git a/src/java/org/apache/poi/hssf/record/StringRecord.java b/src/java/org/apache/poi/hssf/record/StringRecord.java index 96a22f8bd3..efd86f1f79 100644 --- a/src/java/org/apache/poi/hssf/record/StringRecord.java +++ b/src/java/org/apache/poi/hssf/record/StringRecord.java @@ -23,7 +23,6 @@ import java.util.function.Supplier; import org.apache.poi.hssf.record.cont.ContinuableRecord; import org.apache.poi.hssf.record.cont.ContinuableRecordOutput; import org.apache.poi.util.GenericRecordUtil; -import org.apache.poi.util.Removal; import org.apache.poi.util.StringUtil; /** @@ -86,16 +85,6 @@ public final class StringRecord extends ContinuableRecord { _is16bitUnicode = StringUtil.hasMultibyte(string); } - /** - * @deprecated use {@link #copy()} instead - */ - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public StringRecord clone() { - return copy(); - } - public StringRecord copy() { return new StringRecord(this); } diff --git a/src/java/org/apache/poi/hssf/record/TextObjectRecord.java b/src/java/org/apache/poi/hssf/record/TextObjectRecord.java index c3377e2c89..8beeb3a621 100644 --- a/src/java/org/apache/poi/hssf/record/TextObjectRecord.java +++ b/src/java/org/apache/poi/hssf/record/TextObjectRecord.java @@ -30,7 +30,6 @@ import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.RecordFormatException; -import org.apache.poi.util.Removal; /** * The TXO record (0x01B6) is used to define the properties of a text box. It is @@ -317,17 +316,6 @@ public final class TextObjectRecord extends ContinuableRecord { return _linkRefPtg; } - /** - * @deprecated use {@link #copy()} instead - */ - @Override - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public TextObjectRecord clone() { - return copy(); - } - @Override public TextObjectRecord copy() { return new TextObjectRecord(this); diff --git a/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java b/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java index 7644a54417..bd28b190c2 100644 --- a/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java +++ b/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java @@ -17,8 +17,6 @@ package org.apache.poi.hssf.record; -import org.apache.poi.util.Removal; - /** * VerticalPageBreak (0x001A) record that stores page breaks at columns * @@ -48,17 +46,6 @@ public final class VerticalPageBreakRecord extends PageBreakRecord { return sid; } - /** - * @deprecated use {@link #copy()} instead - */ - @Override - @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"}) - @Deprecated - @Removal(version = "5.0.0") - public VerticalPageBreakRecord clone() { - return copy(); - } - @Override public VerticalPageBreakRecord copy() { return new VerticalPageBreakRecord(this); diff --git a/src/java/org/apache/poi/util/IOUtils.java b/src/java/org/apache/poi/util/IOUtils.java index 68f5bbddc5..fc75f4f652 100644 --- a/src/java/org/apache/poi/util/IOUtils.java +++ b/src/java/org/apache/poi/util/IOUtils.java @@ -33,9 +33,6 @@ import java.util.zip.CRC32; import java.util.zip.Checksum; import org.apache.poi.EmptyFileException; -import org.apache.poi.POIDocument; -import org.apache.poi.ss.usermodel.Workbook; - @Internal public final class IOUtils { @@ -290,137 +287,6 @@ public final class IOUtils { } } - /** - * Write a POI Document ({@link org.apache.poi.ss.usermodel.Workbook}, {@link org.apache.poi.sl.usermodel.SlideShow}, etc) to an output stream and close the output stream. - * This will attempt to close the output stream at the end even if there was a problem writing the document to the stream. - * - * If you are using Java 7 or higher, you may prefer to use a try-with-resources statement instead. - * This function exists for Java 6 code. - * - * @param doc a writeable document to write to the output stream - * @param out the output stream that the document is written to - * @throws IOException thrown on errors writing to the stream - * - * @deprecated since 4.0, use try-with-resources, will be removed in 4.2 - */ - @Deprecated - @Removal(version="4.2") - public static void write(POIDocument doc, OutputStream out) throws IOException { - try { - doc.write(out); - } finally { - closeQuietly(out); - } - } - - /** - * Write a ({@link org.apache.poi.ss.usermodel.Workbook}) to an output stream and close the output stream. - * This will attempt to close the output stream at the end even if there was a problem writing the document to the stream. - * - * If you are using Java 7 or higher, you may prefer to use a try-with-resources statement instead. - * This function exists for Java 6 code. - * - * @param doc a writeable document to write to the output stream - * @param out the output stream that the document is written to - * @throws IOException thrown on errors writing to the stream - * - * @deprecated since 4.0, use try-with-resources, will be removed in 4.2 - */ - @Deprecated - @Removal(version="4.2") - public static void write(Workbook doc, OutputStream out) throws IOException { - try { - doc.write(out); - } finally { - closeQuietly(out); - } - } - - /** - * Write a POI Document ({@link org.apache.poi.ss.usermodel.Workbook}, {@link org.apache.poi.sl.usermodel.SlideShow}, etc) to an output stream and close the output stream. - * This will attempt to close the output stream at the end even if there was a problem writing the document to the stream. - * This will also attempt to close the document, even if an error occurred while writing the document or closing the output stream. - * - * If you are using Java 7 or higher, you may prefer to use a try-with-resources statement instead. - * This function exists for Java 6 code. - * - * @param doc a writeable and closeable document to write to the output stream, then close - * @param out the output stream that the document is written to - * @throws IOException thrown on errors writing to the stream - * - * @deprecated since 4.0, use try-with-resources, will be removed in 4.2 - */ - @Deprecated - @Removal(version="4.2") - public static void writeAndClose(POIDocument doc, OutputStream out) throws IOException { - try { - write(doc, out); - } finally { - closeQuietly(doc); - } - } - - /** - * Like {@link #writeAndClose(POIDocument, OutputStream)}, but for writing to a File instead of an OutputStream. - * This will attempt to close the document, even if an error occurred while writing the document. - * - * If you are using Java 7 or higher, you may prefer to use a try-with-resources statement instead. - * This function exists for Java 6 code. - * - * @param doc a writeable and closeable document to write to the output file, then close - * @param out the output file that the document is written to - * @throws IOException thrown on errors writing to the stream - * - * @deprecated since 4.0, use try-with-resources, will be removed in 4.2 - */ - @Deprecated - @Removal(version="4.2") - public static void writeAndClose(POIDocument doc, File out) throws IOException { - try { - doc.write(out); - } finally { - closeQuietly(doc); - } - } - - /** - * Like {@link #writeAndClose(POIDocument, File)}, but for writing a POI Document in place (to the same file that it was opened from). - * This will attempt to close the document, even if an error occurred while writing the document. - * - * If you are using Java 7 or higher, you may prefer to use a try-with-resources statement instead. - * This function exists for Java 6 code. - * - * @param doc a writeable document to write in-place - * @throws IOException thrown on errors writing to the file - * - * @deprecated since 4.0, use try-with-resources, will be removed in 4.2 - */ - @Deprecated - @Removal(version="4.2") - public static void writeAndClose(POIDocument doc) throws IOException { - try { - doc.write(); - } finally { - closeQuietly(doc); - } - } - - // Since the Workbook interface doesn't derive from POIDocument - // We'll likely need one of these for each document container interface - /** - * - * @deprecated since 4.0, use try-with-resources, will be removed in 4.2 - */ - @Deprecated - @Removal(version="4.2") - public static void writeAndClose(Workbook doc, OutputStream out) throws IOException { - try { - doc.write(out); - } finally { - closeQuietly(doc); - } - } - /** * Copies all the data from the given InputStream to the OutputStream. It * leaves both streams open, so you will still need to close them once done. -- 2.39.5