sonar fixes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1735321 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2016-03-16 22:27:56 +00:00
parent d6d47e0bca
commit d749785d1f
3 changed files with 8 additions and 8 deletions

View File

@ -39,7 +39,7 @@ public class HybridStreaming {
private static final String SHEET_TO_STREAM = "large sheet"; private static final String SHEET_TO_STREAM = "large sheet";
public static void main(String[] args) throws IOException, SAXException { 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) { XSSFWorkbook workbook = new XSSFWorkbook(sourceBytes) {
/** Avoid DOM parse of large sheet */ /** Avoid DOM parse of large sheet */
public void parseSheet(java.util.Map<String,XSSFSheet> shIdMap, CTSheet ctSheet) { public void parseSheet(java.util.Map<String,XSSFSheet> shIdMap, CTSheet ctSheet) {
@ -53,6 +53,7 @@ public class HybridStreaming {
ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(workbook.getPackage()); ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(workbook.getPackage());
new XSSFSheetXMLHandler(workbook.getStylesSource(), strings, createSheetContentsHandler(), false); new XSSFSheetXMLHandler(workbook.getStylesSource(), strings, createSheetContentsHandler(), false);
workbook.close(); workbook.close();
sourceBytes.close();
} }
private static SheetContentsHandler createSheetContentsHandler() { private static SheetContentsHandler createSheetContentsHandler() {

View File

@ -63,7 +63,7 @@ public class WorkingWithPictures {
//save workbook //save workbook
String file = "picture.xls"; String file = "picture.xls";
if(wb instanceof XSSFWorkbook) file += "x"; if(wb instanceof XSSFWorkbook) file += "x"; // NOSONAR
OutputStream fileOut = new FileOutputStream(file); OutputStream fileOut = new FileOutputStream(file);
try { try {
wb.write(fileOut); wb.write(fileOut);

View File

@ -86,6 +86,8 @@ public class SimpleTable {
FileOutputStream out = new FileOutputStream("simpleTable.docx"); FileOutputStream out = new FileOutputStream("simpleTable.docx");
doc.write(out); doc.write(out);
out.close(); out.close();
doc.close();
} }
/** /**
@ -174,13 +176,8 @@ public class SimpleTable {
rh.setBold(true); rh.setBold(true);
para.setAlignment(ParagraphAlignment.CENTER); para.setAlignment(ParagraphAlignment.CENTER);
} }
else if (rowCt % 2 == 0) {
// even row
rh.setText("row " + rowCt + ", col " + colCt);
para.setAlignment(ParagraphAlignment.LEFT);
}
else { else {
// odd row // other rows
rh.setText("row " + rowCt + ", col " + colCt); rh.setText("row " + rowCt + ", col " + colCt);
para.setAlignment(ParagraphAlignment.LEFT); para.setAlignment(ParagraphAlignment.LEFT);
} }
@ -194,6 +191,8 @@ public class SimpleTable {
FileOutputStream out = new FileOutputStream("styledTable.docx"); FileOutputStream out = new FileOutputStream("styledTable.docx");
doc.write(out); doc.write(out);
out.close(); out.close();
doc.close();
} }
} }