Scala学习9之产生随机数并写入到文件中

来源:互联网 发布:戴森无叶风扇 知乎 编辑:程序博客网 时间:2024/04/30 15:49


代码:

package Chapter4import scala.io.Sourceimport java.io.PrintWriterimport java.io.Fileimport java.util._;import java.text.SimpleDateFormat//import object ProduceRandom {  def main(args: Array[String]): Unit = {    val n = 100000    val m = 100    val iString = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())    val soutput = "file/output/" + iString;    val w1 = new PrintWriter(new File("file/output/file" + iString + ".txt"))    //      for (i<- 0 to n-1) {    //      val uu=new Random()    //      println(uu.nextInt(10))    ////      arr(i)=uu.nextInt(n);    ////      println(i+":"+arr(i))    //      }    //     for(i <- 1 to 10 ) println(Rond)    var uu = new Random()    for (i <- 1 to n) { w1.println(uu.nextInt(m)) }    println("success")    w1.close()  }}

结果:部分

999265167614785519760


0 0
原创粉丝点击