def testPrintAndWriter()= { val line = StdIn.readLine() val writer = new PrintWriter(new File("test.txt" )) writer.write("sea write "+line) writer.close() println("文件内容为:" ) Source.fromFile("test.txt" ).foreach{ print } }