|
19 | 19 | import java.io.File; |
20 | 20 | import java.io.FileOutputStream; |
21 | 21 | import java.io.IOException; |
22 | | -import java.nio.file.FileSystems; |
23 | 22 | import java.util.List; |
24 | 23 | import java.util.Map; |
25 | 24 | import java.util.Map.Entry; |
@@ -62,7 +61,7 @@ public static void main( String[] args ) throws IOException |
62 | 61 | } |
63 | 62 |
|
64 | 63 | File pdfFile = new File(args[0]); |
65 | | - String directoryPath = pdfFile.getParent() + FileSystems.getDefault().getSeparator(); |
| 64 | + String directoryPath = pdfFile.getParent(); |
66 | 65 | try (PDDocument document = Loader.loadPDF(pdfFile)) |
67 | 66 | { |
68 | 67 | PDDocumentNameDictionary namesDictionary = |
@@ -140,16 +139,15 @@ private static void extractFiles(Map<String, PDComplexFileSpecification> names, |
140 | 139 | private static void extractFile(String filename, PDEmbeddedFile embeddedFile, String directoryPath) |
141 | 140 | throws IOException |
142 | 141 | { |
143 | | - String embeddedFilename = directoryPath + filename; |
144 | | - File file = new File(embeddedFilename); |
| 142 | + File file = new File(directoryPath, filename); |
145 | 143 | File parentDir = file.getParentFile(); |
146 | 144 | if (!parentDir.exists()) |
147 | 145 | { |
148 | 146 | // sometimes paths contain a directory |
149 | 147 | System.out.println("Creating " + parentDir); |
150 | 148 | parentDir.mkdirs(); |
151 | 149 | } |
152 | | - System.out.println("Writing " + embeddedFilename); |
| 150 | + System.out.println("Writing " + file); |
153 | 151 | try (FileOutputStream fos = new FileOutputStream(file)) |
154 | 152 | { |
155 | 153 | fos.write(embeddedFile.toByteArray()); |
|
0 commit comments