]> source.dussan.org Git - poi.git/commitdiff
sonar fixes
authorAndreas Beeker <kiwiwings@apache.org>
Wed, 16 Mar 2016 22:27:56 +0000 (22:27 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Wed, 16 Mar 2016 22:27:56 +0000 (22:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1735321 13f79535-47bb-0310-9956-ffa450edef68

src/examples/src/org/apache/poi/xssf/streaming/examples/HybridStreaming.java
src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java
src/examples/src/org/apache/poi/xwpf/usermodel/SimpleTable.java

index ffa2891fd0a676bb1db4c2005bcd93edd6d82775..f2ceb5e1d4d9ce1f9f4a17cce74cdd7934bb589c 100644 (file)
@@ -39,7 +39,7 @@ public class HybridStreaming {
     private static final String SHEET_TO_STREAM = "large sheet";
 
     public static void main(String[] args) throws IOException, SAXException {
-        InputStream sourceBytes = new FileInputStream("/path/too/workbook.xlsx");
+        InputStream sourceBytes = new FileInputStream("workbook.xlsx");
         XSSFWorkbook workbook = new XSSFWorkbook(sourceBytes) {
             /** Avoid DOM parse of large sheet */
             public void parseSheet(java.util.Map<String,XSSFSheet> shIdMap, CTSheet ctSheet) {
@@ -53,6 +53,7 @@ public class HybridStreaming {
         ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(workbook.getPackage());
         new XSSFSheetXMLHandler(workbook.getStylesSource(), strings, createSheetContentsHandler(), false);
         workbook.close();
+        sourceBytes.close();
     }
 
     private static SheetContentsHandler createSheetContentsHandler() {
index 6607beb3fce95c7c6c848d7cc96de6708d046ae4..e7aeaaac1167cecb72375721905b7a21cc97750f 100644 (file)
@@ -63,7 +63,7 @@ public class WorkingWithPictures {
     
             //save workbook
             String file = "picture.xls";
-            if(wb instanceof XSSFWorkbook) file += "x";
+            if(wb instanceof XSSFWorkbook) file += "x"; // NOSONAR
             OutputStream fileOut = new FileOutputStream(file);
             try {
                 wb.write(fileOut);
index 5f049ba0ac0529a9841a1b26c738ea5855cc6ffa..5d07fe21641591f633661e048365c89d32d49547 100644 (file)
@@ -86,6 +86,8 @@ public class SimpleTable {
         FileOutputStream out = new FileOutputStream("simpleTable.docx");
         doc.write(out);
         out.close();
+        
+        doc.close();
     }
 
     /**
@@ -174,13 +176,8 @@ public class SimpleTable {
                        rh.setBold(true);
                     para.setAlignment(ParagraphAlignment.CENTER);
                 }
-               else if (rowCt % 2 == 0) {
-                       // even row
-                    rh.setText("row " + rowCt + ", col " + colCt);
-                    para.setAlignment(ParagraphAlignment.LEFT);
-               }
                else {
-                       // odd row
+                       // other rows
                     rh.setText("row " + rowCt + ", col " + colCt);
                     para.setAlignment(ParagraphAlignment.LEFT);
                }
@@ -194,6 +191,8 @@ public class SimpleTable {
         FileOutputStream out = new FileOutputStream("styledTable.docx");
         doc.write(out);
         out.close();
+        
+        doc.close();
     }
 
 }