import java.io.{File, PrintWriter}
import scala.io.Source
object no4
{
def main(args: Array[String]): Unit = {
//从文件中读取数据
Source.fromFile("C:/Users/zhang/IdeaProjects/untitled2/.idea/test.txt").foreach(print)
//将数据写入文件
val writer = new PrintWriter(new File("C:\\Users\\zhang\\IdeaProjects\\untitled2\\.idea\\zml.txt"))
writer.write("zxcvbnmasdfghjkl")
writer.close()
//(1)自动提升原则:多种类型的数值运算时,系统首先自动将所有数据转换成精度大的类型
val x :Byte = 10
val z: Long = 6666l
val sum:Long = z + x
val sum1:Int = ((z + x).toInt) //强制类型转换
//(2)把高精度赋给低精度会报错,反之会进行数据转换
//(3)(byte,short)和char之间不会相互自动转换
//(4)byte,short,char他们三者可以进行计算,在计算之前先转换成Int类型
//数值转String
val m:Int = 6
val n:String = m + ""
println(n)
//Sting转数值
val o:Int = "123".toInt
val o1:Float = "120.3" .toFloat
val o2 :Int = "120.3".toDouble.toInt
println(o2)
val y:Int = 129
val y1:Byte = y.toByte
println(y1)
}
10
}