]> source.dussan.org Git - poi.git/commitdiff
fix forbidden-apis-check error
authorAndreas Beeker <kiwiwings@apache.org>
Sat, 31 Dec 2016 21:37:14 +0000 (21:37 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sat, 31 Dec 2016 21:37:14 +0000 (21:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1776817 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/dev/OOXMLLister.java
src/ooxml/testcases/org/apache/poi/dev/TestOOXMLLister.java

index 79d7bed6108cb8017be7006fabf43b1d4af07d43..b82d92136e65007584dd3d593a5af4be5fefa660 100644 (file)
@@ -122,7 +122,7 @@ public class OOXMLLister implements Closeable {
                container.close();
        }
 
-       public static void main(String[] args) throws Exception {
+       public static void main(String[] args) throws IOException, InvalidFormatException {
                if(args.length == 0) {
                        System.err.println("Use:");
                        System.err.println("\tjava OOXMLLister <filename>");
index 94b01173d85e548624719181af2f58dc779d418b..cb883c8765d2de9d74dd084dfb603db95278301d 100644 (file)
 ==================================================================== */
 package org.apache.poi.dev;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackageAccess;
 import org.apache.poi.util.NullOutputStream;
 import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.junit.Test;
 
-import java.io.File;
-import java.io.PrintStream;
-
 public class TestOOXMLLister {
     @Test
-    public void testMain() throws Exception {
+    public void testMain() throws IOException, InvalidFormatException {
         File file = XSSFTestDataSamples.getSampleFile("Formatting.xlsx");
         OOXMLLister.main(new String[] {file.getAbsolutePath()});
     }
 
     @Test
-    public void testWithPrintStream() throws Exception {
+    public void testWithPrintStream() throws IOException, InvalidFormatException {
         File file = XSSFTestDataSamples.getSampleFile("Formatting.xlsx");
-        OOXMLLister lister = new OOXMLLister(OPCPackage.open(file.getAbsolutePath(), PackageAccess.READ), new PrintStream(new NullOutputStream()));
+        PrintStream nullStream = new PrintStream(new NullOutputStream(), true, "UTF-8");
+        OPCPackage opc = OPCPackage.open(file.getAbsolutePath(), PackageAccess.READ);
+        OOXMLLister lister = new OOXMLLister(opc, nullStream);
         lister.displayParts();
         lister.displayRelations();
         lister.close();
+        opc.close();
+        nullStream.close();
     }
 }