Scala File 文件操作

2019-03-14 15:50:55 浏览数 (1)

写文件

代码语言:javascript复制
package com.bi

import java.io.{File, PrintWriter}

/**
  * Created by xxx on 2017/6/30.
  */
object FileHandler {
  def fileWriter(fileName: String, content: String): Unit = {
    val writer = new PrintWriter(new File(fileName))
    writer.write(content)
    writer.close()
  }

  def main(args: Array[String]): Unit = {
    fileWriter("ssss", "sdfadffffffffffffff")
    fileWriter("ssss", "2222222222222222222222222222")
  }
}

0 人点赞