标签:print tle java 写入 file fromfile import mfile line
import java.io.PrintWriter
import java.io.File
import scala.io.Source
object FileOps {
def main(args:Array[String]){
//文件读取
val file=Source.fromFile("D:\\a.txt")
for(line <- file.getLines)
{
println(line)
}
file.close
//文件写入
val writer = new PrintWriter(new File("D:\\saveTextTitle.txt"))
for(i <- 1 to 10)
writer.println(i)// 这里是自动换行 不用再加\n 切记切记
writer.close()
}
}
标签:print tle java 写入 file fromfile import mfile line
原文地址:https://www.cnblogs.com/alpha-cat/p/11651556.html