当前位置:网站首页>Scala IO read by line
Scala IO read by line
2022-06-25 01:03:00 【Jue Niu thunder plough hot blade】
import scala.io.Source
// Source Class extends from Iterator
object D01_ According to the line read {
def main(args: Array[String]): Unit = {
// Register target objects
val source = Source.fromFile("./data/1.txt", "utf-8")
// Read in line bit units
val lines: Iterator[String] = source.getLines()
val list = lines.toList
for (data <- list) println(data)
// Release resources
source.close()
}
}
1.txt data
The spring river and the moon
【 author 】 Zhang Ruoxu 【 Dynasty 】
The spring tide is even with the sea , The moon and the tide rise in the sea .
With the waves of thousands of miles , Where is the spring river without the moon !
The river flows around Fangdian , All the flowers in the forest are like graupel ;
I don't feel the frost flying in the air , White sand can't see on Ting .
There is no fine dust in the river , The lone moon in the sky .
Who by the river saw the moon for the first time ? At the beginning of the year, Jiang Yue took photos of people ?
Life is endless , Jiang Yue looks similar every year .
I don't know who Jiang Yue is waiting for , But see the Yangtze River sending water .
White clouds go all the way , The green maple is full of sorrow .
Who's going to boat tonight ? Where is the lovesickness moon tower ?
Poor Yue Pei , You should take a picture of the dressing table .
I can't roll in the Yuhu curtain , Whisk the clothes and anvil .
At this time, we don't know each other , May the moon shine on you .
The long flying light of wild geese is not enough , Fish and Dragons dive into the water .
Last night I dreamed of falling flowers , Poor spring will not return home .
The river flows away in spring , The moon falls on the river and the lake slopes to the West .
The slanting moon sinks into the sea mist , Jieshi Xiaoxiang infinite road .
I don't know how many people will come back in the month , The falling moon shakes all the trees in the river .
1.txt Location
边栏推荐
- Helm chart仓库操作
- 我想问一下兴业证券怎么开户?通过链接办理股票开户安全吗
- ServerSocket and socket connection
- The basic principle and application of iterator and enhanced for
- Can communication experiment between C and C
- The drawableleft of the custom textview in kotlin is displayed in the center together with the text
- 生成订单30分钟未支付,则自动取消,该怎么实现?
- Kubernetes 架构核心组件工作原理解析
- 2022 crane driver (limited to bridge crane) examination question bank simulated examination platform operation
- 打卡smart精灵#1,品牌不缺吸引力,产品本身实力如何?
猜你喜欢
2021-11-07
The basic principle and application of iterator and enhanced for
Custom animation (simulated win10 loading animation)
ros(25):rqt_ image_ View reports an error unable to load plugin for transport 'compressed', error string
Custom animation (simulated win10 loading animation) - Optimization
Activity startup process
Use of JMeter easynmon
Use and click of multitypeadapter in recycleview
Mobile security tool jar
Text editor for QT project practice - Episode 12
随机推荐
Xcode预览(Preview)显示List视图内容的一个Bug及解决
2022年起重机司机(限桥式起重机)考试题库模拟考试平台操作
C# 闭包的垃圾回收
Sanic service startup failed
Usage of assert
[microservices sentinel] cluster link | microservices cluster environment construction
Redis + Lua implementation of distributed interface current limiting
QT (35) - operate excel qxlsx qaxobject
Scala trait exercise
[redis realizes seckill business ③] specific implementation of optimistic lock for oversold problem
iNFTnews | 国内NFT发展仅限于数字藏品吗?
Use of JMeter easynmon
Scala trait inheritance class
[microservices sentinel] sentinel quick start | building an image | starting the console
Scala sample object
Text editor of QT project practice ---------- episode 11
断言(assert)的用法
Sliding window technology based on byte in transport layer
adb shell getevent
ServerSocket and socket connection