def write(fileName: String)(datas: Array[String]): Unit = {
val writer = new PrintWriter(new File(fileName))
println("--------数据写入--------")
for (s <- datas) {
writer.write(s + "\n")
}
writer.close()
}
def read(fileName: String) = {
val txt_data = Source.fromFile(fileName)
val nodes = new ArrayBuffer[String]()
val array = txt_data.getLines().filter(x => x.isInstanceOf[String]).toArray
array.foreach(
x => {
nodes.append(x)
}
)
nodes
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-13759.html