]> git.basschouten.com Git - openhab-addons.git/commitdiff
Migrate to java.nio.file.createTempFile (#15469)
authorHolger Friedrich <holgerfriedrich@users.noreply.github.com>
Sat, 9 Sep 2023 09:10:32 +0000 (11:10 +0200)
committerGitHub <noreply@github.com>
Sat, 9 Sep 2023 09:10:32 +0000 (11:10 +0200)
Use function from nio package as it uses more restrictive file
permissions.

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
bundles/org.openhab.binding.icalendar/src/main/java/org/openhab/binding/icalendar/internal/handler/PullJob.java
bundles/org.openhab.voice.mactts/src/main/java/org/openhab/voice/mactts/internal/MacTTSAudioStream.java
bundles/org.openhab.voice.picotts/src/main/java/org/openhab/voice/picotts/internal/PicoTTSAudioStream.java

index 6dc411702c7b55b03d8af84bd379cc3e3b159e82..84275f8218b8657b9897c5638b6652e8e2452c76 100644 (file)
@@ -143,7 +143,7 @@ class PullJob implements Runnable {
 
         File tmpTargetFile;
         try {
-            tmpTargetFile = File.createTempFile(TMP_FILE_PREFIX, null);
+            tmpTargetFile = Files.createTempFile(TMP_FILE_PREFIX, null).toFile();
         } catch (IOException e) {
             logger.warn("Not able to create temporary file for downloading iCal. Error message is: {}", e.getMessage());
             return;
index b83dcdae4ba150a408a1d08b8a7e763a8e38413d..c6bfeb29e079506dc17ed6b2d96d11b59a5a491a 100644 (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.openhab.core.audio.AudioException;
 import org.openhab.core.audio.AudioFormat;
@@ -130,7 +131,7 @@ class MacTTSAudioStream extends FixedLengthAudioStream implements Disposable {
     private String generateOutputFilename() throws AudioException {
         File tempFile;
         try {
-            tempFile = File.createTempFile(Integer.toString(text.hashCode()), ".wav");
+            tempFile = Files.createTempFile(Integer.toString(text.hashCode()), ".wav").toFile();
             tempFile.deleteOnExit();
         } catch (IOException e) {
             throw new AudioException("Unable to create temp file.", e);
index da384f443c373e1d16466469f2de5034fd3b29bd..5d0c5288323a39837eceb43b4735f88910a286ee 100644 (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) {