【发布时间】:2019-10-09 10:49:12
【问题描述】:
这里的语法我真的很乱,需要帮助...
我有一个 URL,点击后会下载 sample.csv.gz 文件
请有人帮我填补下面的语法空白:
val outputFile = "C:\\sampleNew" + ".csv"
val inputFile = "C:\\sample.csv.gz"
val fileUrl = "someSamplehttpUrl"
// On hitting this Url, sample.csv.gz file should download at destination 'outputFile'
val in = new URL()(fileUrl).openStream()
Files.copy(in, Paths.get(outputFile), StandardCopyOption.REPLACE_EXISTING)
val filePath = new File(outputFile)
if(filePath.exists()) filePath.delete()
val fw = new FileWriter(outputFile, true)
var bf = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(inputFile)), "UTF-8"))
while (bf.ready()) fw.append(bf.readLine() + "\n")
我遇到了几个语法错误...这里有什么更正吗?我基本上有一个返回 URL 的 http get 请求,我必须打开它才能下载这个 gz 文件
谢谢!
【问题讨论】:
标签: scala csv http gzip get-request