[BAHIR-172 ] Replace FileInputStream with Files.newInputStream (#92)
diff --git a/sql-streaming-mqtt/src/test/scala/org/apache/bahir/sql/streaming/mqtt/MQTTTestUtils.scala b/sql-streaming-mqtt/src/test/scala/org/apache/bahir/sql/streaming/mqtt/MQTTTestUtils.scala
index b891c93..ba04599 100644
--- a/sql-streaming-mqtt/src/test/scala/org/apache/bahir/sql/streaming/mqtt/MQTTTestUtils.scala
+++ b/sql-streaming-mqtt/src/test/scala/org/apache/bahir/sql/streaming/mqtt/MQTTTestUtils.scala
@@ -18,9 +18,9 @@
package org.apache.bahir.sql.streaming.mqtt
import java.io.File
-import java.io.FileInputStream
import java.net.{ServerSocket, URI}
import java.nio.charset.Charset
+import java.nio.file.Files
import java.security.{KeyStore, SecureRandom}
import java.util.Properties
import javax.net.ssl.KeyManagerFactory
@@ -63,7 +63,7 @@
val protocol = if (ssl) "mqtt+ssl" else "mqtt"
if (ssl) {
val keyStore = KeyStore.getInstance("JKS")
- keyStore.load(new FileInputStream(serverKeyStore), serverKeyStorePassword.toCharArray)
+ keyStore.load(Files.newInputStream(serverKeyStore.toPath), serverKeyStorePassword.toCharArray)
val keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm)
keyManagerFactory.init(keyStore, serverKeyStorePassword.toCharArray)
broker.setSslContext(
diff --git a/streaming-pubsub/src/main/scala/org/apache/spark/streaming/pubsub/SparkGCPCredentials.scala b/streaming-pubsub/src/main/scala/org/apache/spark/streaming/pubsub/SparkGCPCredentials.scala
index 4352d7f..6121b47 100644
--- a/streaming-pubsub/src/main/scala/org/apache/spark/streaming/pubsub/SparkGCPCredentials.scala
+++ b/streaming-pubsub/src/main/scala/org/apache/spark/streaming/pubsub/SparkGCPCredentials.scala
@@ -86,7 +86,7 @@
override def provider: Credential = {
val tempFile = File.createTempFile(emailAccount, ".p12")
tempFile.deleteOnExit()
- val p12Out = new FileOutputStream(tempFile)
+ val p12Out = Files.newOutputStream(tempFile.toPath)
p12Out.write(p12Content, 0, p12Content.length)
p12Out.flush()
p12Out.close()