From: Dominik Stadler Date: Thu, 23 Aug 2018 13:34:25 +0000 (+0000) Subject: Remove some IDE warnings X-Git-Tag: REL_4_0_0_FINAL~26 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bcc68c5f2003d10485f837a1e9442511656882b3;p=poi.git Remove some IDE warnings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1838733 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java index eb22cc1d48..23da1e1f02 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java +++ b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java @@ -27,7 +27,6 @@ import java.io.FilenameFilter; import java.io.IOException; import java.util.ArrayList; -import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.DataFormatter; @@ -182,13 +181,10 @@ public class ToCSV { * exist or if the value passed to the strDestination paramater refers * to a folder that does not exist or simply does not refer to a * folder. - * @throws org.apache.poi.openxml4j.exceptions.InvalidFormatException Thrown - * if the xml markup encountered whilst parsing a SpreadsheetML - * file (.xlsx) is invalid. */ public void convertExcelToCSV(String strSource, String strDestination) throws FileNotFoundException, IOException, - IllegalArgumentException, InvalidFormatException { + IllegalArgumentException { // Simply chain the call to the overloaded convertExcelToCSV(String, // String, String, int) method, pass the default separator and ensure @@ -226,14 +222,11 @@ public class ToCSV { * exist or if the value passed to the strDestination paramater refers * to a folder that does not exist or simply does not refer to a * folder. - * @throws org.apache.poi.openxml4j.exceptions.InvalidFormatException Thrown - * if the xml markup encounetered whilst parsing a SpreadsheetML - * file (.xlsx) is invalid. */ public void convertExcelToCSV(String strSource, String strDestination, String separator) throws FileNotFoundException, IOException, - IllegalArgumentException, InvalidFormatException { + IllegalArgumentException { // Simply chain the call to the overloaded convertExcelToCSV(String, // String, String, int) method and ensure that certain embedded @@ -275,14 +268,11 @@ public class ToCSV { * value passed to the formattingConvention parameter is other than * one of the values defined by the constants ToCSV.EXCEL_STYLE_ESCAPING * and ToCSV.UNIX_STYLE_ESCAPING. - * @throws org.apache.poi.openxml4j.exceptions.InvalidFormatException Thrown - * if the xml markup encounetered whilst parsing a SpreadsheetML - * file (.xlsx) is invalid. */ public void convertExcelToCSV(String strSource, String strDestination, String separator, int formattingConvention) throws FileNotFoundException, IOException, - IllegalArgumentException, InvalidFormatException { + IllegalArgumentException { File source = new File(strSource); File destination = new File(strDestination); File[] filesList; @@ -374,17 +364,11 @@ public class ToCSV { * either binary (.xls) or SpreadsheetML (.xlsx) format. * @throws java.io.FileNotFoundException Thrown if the file cannot be located. * @throws java.io.IOException Thrown if a problem occurs in the file system. - * @throws org.apache.poi.openxml4j.exceptions.InvalidFormatException Thrown - * if invalid xml is found whilst parsing an input SpreadsheetML - * file. */ private void openWorkbook(File file) throws FileNotFoundException, - IOException, InvalidFormatException { - FileInputStream fis = null; - try { - System.out.println("Opening workbook [" + file.getName() + "]"); - - fis = new FileInputStream(file); + IOException { + System.out.println("Opening workbook [" + file.getName() + "]"); + try (FileInputStream fis = new FileInputStream(file)) { // Open the workbook and then create the FormulaEvaluator and // DataFormatter instances that will be needed to, respectively, @@ -394,11 +378,6 @@ public class ToCSV { this.evaluator = this.workbook.getCreationHelper().createFormulaEvaluator(); this.formatter = new DataFormatter(true); } - finally { - if(fis != null) { - fis.close(); - } - } } /** diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java index f5ad1f1706..a9e214586f 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java @@ -46,12 +46,12 @@ public abstract class XDDFChartData { private List valueAxes; protected XDDFChartData() { - this.series = new ArrayList(); + this.series = new ArrayList<>(); } protected void defineAxes(CTUnsignedInt[] axes, Map categories, Map values) { - List list = new ArrayList(axes.length); + List list = new ArrayList<>(axes.length); for (CTUnsignedInt axe : axes) { Long axisId = axe.getVal(); XDDFChartAxis category = categories.get(axisId); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/model/TestSharedStringsTable.java b/src/ooxml/testcases/org/apache/poi/xssf/model/TestSharedStringsTable.java index 18ee293dc3..2e4de97ebe 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/model/TestSharedStringsTable.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/model/TestSharedStringsTable.java @@ -182,6 +182,7 @@ public final class TestSharedStringsTable extends TestCase { assertEquals("Second string", sst.getItemAt(2).toString()); } + @SuppressWarnings("deprecation") public void testReadWrite() throws IOException { XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("sample.xlsx"); SharedStringsTable sst1 = wb1.getSharedStringSource();