基本上,我想从一个base64字符串内容创建一个临时文件。现在,我使用本地java-io函数来实现这一点。但是我想使用Scala的rapture-io库来达到相同的结果。
所以我的问题是,是否可以使用rapture-io实现这一点,如果可以,如何实现?
我已经查阅了文档,但不够具体。
所以我的问题是,是否可以使用rapture-io实现这一点,如果可以,如何实现?
我已经查阅了文档,但不够具体。
https://github.com/propensive/rapture-io/blob/master/doc/introduction.md
这是我的实际代码:
import org.apache.commons.codec.binary.Base64
import java.io.FileOutputStream
import java.io.File
val data: String = base64StringContent //Base64 String content of the file.
val fileName = myFileName
val fileExt = myFileExt
//It does write the file in my temp folder.
val file: File = File.createTempFile(fileName, fileExt)
val fileByteArray: Array[Byte] = Base64.decodeBase64(data)
val fileOutFile: FileOutputStream = new FileOutputStream(file)
fileOutFile.write(fileByteArray)
fileOutFile.close()
file.deleteOnExit()
file