import java.io._
import scala.util.parsing.json.JSON
class ReadSvd {
val svdFilePath: String = "D:\\aa\\test.svd"
def genSvdInfo(svdName: String) = {
val fileName: String = svdFilePath + svdName + ".svd"
val file = new File(fileName)
var reader: BufferedReader = null
var tempString: String = ""
try {
val isr = new InputStreamReader(new FileInputStream(file), "utf-8")
reader = new BufferedReader(isr)
/*var line = 1
while ((tempString = reader.readLine()) != null){
line+=1
// tempString = reader.readLine()
}*/
tempString = reader.readLine()
reader.close()
} catch {
case e: Exception => {
log.error(s"reader svd Error:${e}+++${e.getStackTrace}+++++${e.getStackTraceString}++++${e.printStackTrace()}")
}
} finally {
if (reader != null) {
try {
reader.close()
} catch {
case e: Exception => {
log.error(s"reader svd Error:${e}+++${e.getStackTrace}+++++${e.getStackTraceString}++++${e.printStackTrace()}")
}
}
}
}
JSON.parseFull(tempString)
tempString
}
}
Scala 读取SVD文件转成JSON
最新推荐文章于 2024-10-17 13:17:45 发布