use try with resources
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1818786 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7cdaeba856
commit
12f82dd617
@ -617,10 +617,11 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
srcSheet.write(out);
|
srcSheet.write(out);
|
||||||
clonedSheet.read(new ByteArrayInputStream(out.toByteArray()));
|
try (ByteArrayInputStream bis = new ByteArrayInputStream(out.toByteArray())) {
|
||||||
|
clonedSheet.read(bis);
|
||||||
|
}
|
||||||
} catch (IOException e){
|
} catch (IOException e){
|
||||||
throw new POIXMLException("Failed to clone sheet", e);
|
throw new POIXMLException("Failed to clone sheet", e);
|
||||||
}
|
}
|
||||||
@ -2366,18 +2367,19 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
|
|||||||
|
|
||||||
Ole10Native ole10 = new Ole10Native(label, fileName, command, oleData);
|
Ole10Native ole10 = new Ole10Native(label, fileName, command, oleData);
|
||||||
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(oleData.length+500);
|
try (ByteArrayOutputStream bos = new ByteArrayOutputStream(oleData.length+500)) {
|
||||||
ole10.writeOut(bos);
|
ole10.writeOut(bos);
|
||||||
|
|
||||||
try (POIFSFileSystem poifs = new POIFSFileSystem()) {
|
try (POIFSFileSystem poifs = new POIFSFileSystem()) {
|
||||||
DirectoryNode root = poifs.getRoot();
|
DirectoryNode root = poifs.getRoot();
|
||||||
root.createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(bos.toByteArray()));
|
root.createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(bos.toByteArray()));
|
||||||
root.setStorageClsid(ClassID.OLE10_PACKAGE);
|
root.setStorageClsid(ClassID.OLE10_PACKAGE);
|
||||||
|
|
||||||
// TODO: generate CombObj stream
|
// TODO: generate CombObj stream
|
||||||
|
|
||||||
try (OutputStream os = pp.getOutputStream()) {
|
try (OutputStream os = pp.getOutputStream()) {
|
||||||
poifs.writeFilesystem(os);
|
poifs.writeFilesystem(os);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user