Migrate to java.nio.file.createTempFile (#15469)

Use function from nio package as it uses more restrictive file
permissions.

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich
2023-09-09 11:10:32 +02:00
committed by GitHub
parent 5e7cbea21f
commit 14c3c0cd63
3 changed files with 5 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@@ -92,7 +93,7 @@ class PicoTTSAudioStream extends FixedLengthAudioStream implements Disposable {
*/
private String generateOutputFilename() throws AudioException {
try {
File tempFile = File.createTempFile(Integer.toString(text.hashCode()), ".wav");
File tempFile = Files.createTempFile(Integer.toString(text.hashCode()), ".wav").toFile();
tempFile.deleteOnExit();
return tempFile.getAbsolutePath();
} catch (IOException e) {