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>pull/15568/head
parent
5e7cbea21f
commit
14c3c0cd63
|
@ -143,7 +143,7 @@ class PullJob implements Runnable {
|
||||||
|
|
||||||
File tmpTargetFile;
|
File tmpTargetFile;
|
||||||
try {
|
try {
|
||||||
tmpTargetFile = File.createTempFile(TMP_FILE_PREFIX, null);
|
tmpTargetFile = Files.createTempFile(TMP_FILE_PREFIX, null).toFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Not able to create temporary file for downloading iCal. Error message is: {}", e.getMessage());
|
logger.warn("Not able to create temporary file for downloading iCal. Error message is: {}", e.getMessage());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
|
||||||
import org.openhab.core.audio.AudioException;
|
import org.openhab.core.audio.AudioException;
|
||||||
import org.openhab.core.audio.AudioFormat;
|
import org.openhab.core.audio.AudioFormat;
|
||||||
|
@ -130,7 +131,7 @@ class MacTTSAudioStream extends FixedLengthAudioStream implements Disposable {
|
||||||
private String generateOutputFilename() throws AudioException {
|
private String generateOutputFilename() throws AudioException {
|
||||||
File tempFile;
|
File tempFile;
|
||||||
try {
|
try {
|
||||||
tempFile = File.createTempFile(Integer.toString(text.hashCode()), ".wav");
|
tempFile = Files.createTempFile(Integer.toString(text.hashCode()), ".wav").toFile();
|
||||||
tempFile.deleteOnExit();
|
tempFile.deleteOnExit();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new AudioException("Unable to create temp file.", e);
|
throw new AudioException("Unable to create temp file.", e);
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
@ -92,7 +93,7 @@ class PicoTTSAudioStream extends FixedLengthAudioStream implements Disposable {
|
||||||
*/
|
*/
|
||||||
private String generateOutputFilename() throws AudioException {
|
private String generateOutputFilename() throws AudioException {
|
||||||
try {
|
try {
|
||||||
File tempFile = File.createTempFile(Integer.toString(text.hashCode()), ".wav");
|
File tempFile = Files.createTempFile(Integer.toString(text.hashCode()), ".wav").toFile();
|
||||||
tempFile.deleteOnExit();
|
tempFile.deleteOnExit();
|
||||||
return tempFile.getAbsolutePath();
|
return tempFile.getAbsolutePath();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
Loading…
Reference in New Issue