close workbook to avoid resource leak

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753053 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-07-17 10:27:44 +00:00
parent d19f614366
commit 5b3a1ad4ce
1 changed files with 4 additions and 2 deletions

View File

@ -17,6 +17,7 @@
package org.apache.poi.xssf.usermodel.examples; package org.apache.poi.xssf.usermodel.examples;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.common.usermodel.HyperlinkType; import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
@ -35,7 +36,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class HyperlinkExample { public class HyperlinkExample {
public static void main(String[]args) throws Exception{ public static void main(String[]args) throws IOException {
Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook(); Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper(); CreationHelper createHelper = wb.getCreationHelper();
@ -91,6 +92,7 @@ public class HyperlinkExample {
FileOutputStream out = new FileOutputStream("hyperinks.xlsx"); FileOutputStream out = new FileOutputStream("hyperinks.xlsx");
wb.write(out); wb.write(out);
out.close(); out.close();
wb.close();
} }
} }