Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

Expand All @@ -46,34 +47,34 @@ public class DefaultResourceExtractor implements ResourceExtractor {
if (stream == null) {
throw new FileNotFoundException(resourceName);
}
File result = createEmptyFile(repository, resourceName);
Files.copy(stream, result.toPath(), StandardCopyOption.REPLACE_EXISTING);
Path result = createEmptyFile(repository.toPath(), resourceName);
Files.copy(stream, result, StandardCopyOption.REPLACE_EXISTING);
if (!persist) {
result.deleteOnExit();
result.toFile().deleteOnExit();
}
return result;
return result.toFile();
}
}

public static Builder builder() {
return new Builder()
.repository(getTempFolder())
.repository(getTempFolder().toFile())
.persist(false);
}

public static DefaultResourceExtractor of(Class<?> anchor) {
return builder().anchor(anchor).build();
}

private static File getTempFolder() {
return Paths.get(System.getProperty("java.io.tmpdir")).toFile();
private static Path getTempFolder() {
return Paths.get(System.getProperty("java.io.tmpdir"));
}

private static File createEmptyFile(File parent, String resourceName) throws IOException {
private static Path createEmptyFile(Path parent, String resourceName) throws IOException {
int idx = resourceName.lastIndexOf(".");
return idx != -1
? File.createTempFile(resourceName.substring(0, idx), resourceName.substring(idx), parent)
: File.createTempFile("rsrc", resourceName, parent);
? Files.createTempFile(parent, "rsrc", resourceName.substring(idx))
: Files.createTempFile(parent, "rsrc", resourceName);
}

// fix javadoc
Expand Down
5 changes: 4 additions & 1 deletion java-sql-lhod/src/test/java/_test/Excel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Optional;

public final class Excel {
Expand All @@ -30,7 +32,8 @@ private static boolean isExcel(OdbcDriver driver) {
}

public static File createTempFile(ArraySheet table) throws IOException {
File excelFile = File.createTempFile("book1", ".xlsx");
Path tempFile = Files.createTempFile("book1", ".xlsx");
File excelFile = tempFile.toFile();
new FastExcelBookFactory().store(excelFile, table.toBook());
return excelFile;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<version>3.4.0</version>
<version>3.5.0</version>
</plugin>
<plugin>
<groupId>de.thetaphi</groupId>
Expand Down
Loading