mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
remove more deprecated code
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1884262 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c1f5d62c35
commit
78596d7891
@ -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);
|
||||
}
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)<p>
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)<p>
|
||||
@ -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);
|
||||
|
||||
@ -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)<p>
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user