aboutsummaryrefslogtreecommitdiffstats
path: root/poi-examples
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-07-20 10:56:16 +0000
committerPJ Fanning <fanningpj@apache.org>2022-07-20 10:56:16 +0000
commit369681f7f9c08124b7af2d75cf531aa08646bc05 (patch)
treee61ca5720ed81087141d13be603d5c7e6474505f /poi-examples
parent48e9d6a6d5df5965d345d61b1f28dbff1dfaf6d7 (diff)
downloadpoi-369681f7f9c08124b7af2d75cf531aa08646bc05.tar.gz
poi-369681f7f9c08124b7af2d75cf531aa08646bc05.zip
use try-with-resources
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902873 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-examples')
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/xslf/AddVideoToPptx.java.txt6
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/xslf/LinkVideoToPptx.java5
2 files changed, 3 insertions, 8 deletions
diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xslf/AddVideoToPptx.java.txt b/poi-examples/src/main/java/org/apache/poi/examples/xslf/AddVideoToPptx.java.txt
index 835fe63d6d..910d264236 100644
--- a/poi-examples/src/main/java/org/apache/poi/examples/xslf/AddVideoToPptx.java.txt
+++ b/poi-examples/src/main/java/org/apache/poi/examples/xslf/AddVideoToPptx.java.txt
@@ -165,16 +165,14 @@ public class AddVideoToPptx {
// see http://msdn.microsoft.com/en-us/library/dd950140(v=office.12).aspx
ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
- XmlCursor cur = ext.newCursor();
- try {
+
+ try (XmlCursor cur = ext.newCursor()) {
cur.toEndToken();
cur.beginElement(new QName(p14Ns, "media", "p14"));
cur.insertNamespace("p14", p14Ns);
cur.insertAttributeWithValue(new QName(STRelationshipId.type.getName().getNamespaceURI(), "embed"), prsEmbed1.getId());
cur.beginElement(new QName(p14Ns, "trim", "p14"));
cur.insertAttributeWithValue("st", df_time.format(seconds*1000.0));
- } finally {
- cur.dispose();
}
}
diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xslf/LinkVideoToPptx.java b/poi-examples/src/main/java/org/apache/poi/examples/xslf/LinkVideoToPptx.java
index 265fa730d4..e86cd791e5 100644
--- a/poi-examples/src/main/java/org/apache/poi/examples/xslf/LinkVideoToPptx.java
+++ b/poi-examples/src/main/java/org/apache/poi/examples/xslf/LinkVideoToPptx.java
@@ -84,14 +84,11 @@ public final class LinkVideoToPptx {
ext.setUri("{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}");
String p14Ns = "http://schemas.microsoft.com/office/powerpoint/2010/main";
- XmlCursor cur = ext.newCursor();
- try {
+ try (XmlCursor cur = ext.newCursor()) {
cur.toEndToken();
cur.beginElement(new QName(p14Ns, "media", "p14"));
cur.insertNamespace("p14", p14Ns);
cur.insertAttributeWithValue(new QName(CORE_PROPERTIES_ECMA376_NS, "link"), prsEmbed1.getId());
- } finally {
- cur.dispose();
}
CTSlide xslide = slide1.getXmlObject();