标签:文件 writer lines fbo close decode form 特殊 write
/**
* 读取文件
* @param filename
* @return
*/
def readFormFile(filename: String) = {
var ooop = ""
val file = Source.fromFile(filename)
for (line <- file.getLines) {
ooop += line
}
file.close
ooop
}
/**
* 保存文件
* @param fielname
* @param html
*/
def saveFileFromUrl(fielname: String, html: String) = {
val writer = new PrintWriter(new File(fielname))
writer.write(html)
writer.close()
}
/**
* 去除不能存储的特殊字符
* @param str
* @return
*/
def zifuChange(str: String): String = {
var bo = true
var encode = URLEncoder.encode(str)
while (bo) {
var t1 = encode.indexOf("%F0")
var zifu = ""
if (t1 > (-1)) {
try {
zifu = encode.substring(t1, t1 + 12)
} catch {
case f: StringIndexOutOfBoundsException => {
zifu = encode.substring(t1, t1 + 3)
}
}
encode = encode.replace(zifu, "")
} else {
bo = false
}
}
URLDecoder.decode(encode)
}
标签:文件 writer lines fbo close decode form 特殊 write
原文地址:https://www.cnblogs.com/hanlong/p/8856582.html