public class EmbeddedObjects {
@SuppressWarnings("unused")
public static void main(String[] args) throws Exception {
- POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(args[0]));
- try (HSSFWorkbook workbook = new HSSFWorkbook(fs)) {
+ try (
+ FileInputStream fis = new FileInputStream(args[0]);
+ POIFSFileSystem fs = new POIFSFileSystem(fis);
+ HSSFWorkbook workbook = new HSSFWorkbook(fs)
+ ) {
for (HSSFObjectData obj : workbook.getAllEmbeddedObjects()) {
//the OLE2 Class Name of the object
String oleName = obj.getOLE2ClassName();
}
public static void viewFileOld(final String filename, boolean withSizes) throws IOException {
- POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(filename));
- displayDirectory(fs.getRoot(), "", withSizes);
- fs.close();
+ try (FileInputStream fis = new FileInputStream(filename)) {
+ POIFSFileSystem fs = new POIFSFileSystem(fis);
+ displayDirectory(fs.getRoot(), "", withSizes);
+ fs.close();
+ }
}
public static void displayDirectory(DirectoryNode dir, String indent, boolean withSizes) {
name = name.substring(1) + " <" + altname + ">";
}
if (withSizes) {
- size = " [" + doc.getSize() + " / 0x" +
+ size = " [" + doc.getSize() + " / 0x" +
Integer.toHexString(doc.getSize()) + "]";
}
System.out.println(newIndent + name + size);
/**
* Locates all the text entries in the file, and returns their
* contents.
- *
+ *
* @return An array of each Text item in the document
*/
public String[] getAllText() {
* Returns the textual contents of the file.
* Each textual object's text will be separated
* by a newline
- *
+ *
* @return All text contained in this document, separated by <code>\n</code>
*/
@Override
System.exit(1);
}
- VisioTextExtractor extractor =
- new VisioTextExtractor(new FileInputStream(args[0]));
+ try (FileInputStream fis = new FileInputStream(args[0])) {
+ VisioTextExtractor extractor =
+ new VisioTextExtractor(fis);
- // Print not PrintLn as already has \n added to it
- System.out.print(extractor.getText());
-
- extractor.close();
+ // Print not PrintLn as already has \n added to it
+ System.out.print(extractor.getText());
+
+ extractor.close();
+ }
}
}
System.err.println(" PLCDumper <filename>");
System.exit(1);
}
- PLCDumper dump = new PLCDumper(
- new FileInputStream(args[0])
- );
- System.out.println("Dumping " + args[0]);
- dump.dumpPLC();
+ try (FileInputStream fis = new FileInputStream(args[0])) {
+ PLCDumper dump = new PLCDumper(fis);
+
+ System.out.println("Dumping " + args[0]);
+ dump.dumpPLC();
+ }
}
private void dumpPLC() {