mirror of https://github.com/apache/poi.git
fix potential input resource leaks (LGTM)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1859591 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
093cbcfcca
commit
8784d6d6d7
|
@ -33,8 +33,11 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
public class EmbeddedObjects {
|
public class EmbeddedObjects {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(args[0]));
|
try (
|
||||||
try (HSSFWorkbook workbook = new HSSFWorkbook(fs)) {
|
FileInputStream fis = new FileInputStream(args[0]);
|
||||||
|
POIFSFileSystem fs = new POIFSFileSystem(fis);
|
||||||
|
HSSFWorkbook workbook = new HSSFWorkbook(fs)
|
||||||
|
) {
|
||||||
for (HSSFObjectData obj : workbook.getAllEmbeddedObjects()) {
|
for (HSSFObjectData obj : workbook.getAllEmbeddedObjects()) {
|
||||||
//the OLE2 Class Name of the object
|
//the OLE2 Class Name of the object
|
||||||
String oleName = obj.getOLE2ClassName();
|
String oleName = obj.getOLE2ClassName();
|
||||||
|
|
|
@ -68,10 +68,12 @@ public class POIFSLister {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void viewFileOld(final String filename, boolean withSizes) throws IOException {
|
public static void viewFileOld(final String filename, boolean withSizes) throws IOException {
|
||||||
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename));
|
try (FileInputStream fis = new FileInputStream(filename)) {
|
||||||
|
POIFSFileSystem fs = new POIFSFileSystem(fis);
|
||||||
displayDirectory(fs.getRoot(), "", withSizes);
|
displayDirectory(fs.getRoot(), "", withSizes);
|
||||||
fs.close();
|
fs.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void displayDirectory(DirectoryNode dir, String indent, boolean withSizes) {
|
public static void displayDirectory(DirectoryNode dir, String indent, boolean withSizes) {
|
||||||
System.out.println(indent + dir.getName() + " -");
|
System.out.println(indent + dir.getName() + " -");
|
||||||
|
|
|
@ -128,8 +128,9 @@ public final class VisioTextExtractor extends POIOLE2TextExtractor {
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try (FileInputStream fis = new FileInputStream(args[0])) {
|
||||||
VisioTextExtractor extractor =
|
VisioTextExtractor extractor =
|
||||||
new VisioTextExtractor(new FileInputStream(args[0]));
|
new VisioTextExtractor(fis);
|
||||||
|
|
||||||
// Print not PrintLn as already has \n added to it
|
// Print not PrintLn as already has \n added to it
|
||||||
System.out.print(extractor.getText());
|
System.out.print(extractor.getText());
|
||||||
|
@ -137,3 +138,4 @@ public final class VisioTextExtractor extends POIOLE2TextExtractor {
|
||||||
extractor.close();
|
extractor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -53,13 +53,14 @@ public final class PLCDumper {
|
||||||
System.err.println(" PLCDumper <filename>");
|
System.err.println(" PLCDumper <filename>");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
PLCDumper dump = new PLCDumper(
|
|
||||||
new FileInputStream(args[0])
|
try (FileInputStream fis = new FileInputStream(args[0])) {
|
||||||
);
|
PLCDumper dump = new PLCDumper(fis);
|
||||||
|
|
||||||
System.out.println("Dumping " + args[0]);
|
System.out.println("Dumping " + args[0]);
|
||||||
dump.dumpPLC();
|
dump.dumpPLC();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void dumpPLC() {
|
private void dumpPLC() {
|
||||||
QCBit[] bits = qc.getBits();
|
QCBit[] bits = qc.getBits();
|
||||||
|
|
Loading…
Reference in New Issue