所以,基本上我想从base64字符串内容创建一个临时文件.现在,我正在使用本机java-io函数.但我想用scala的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
Run Code Online (Sandbox Code Playgroud)