当前位置:网站首页>Scala IO read by character
Scala IO read by character
2022-06-25 01:03:00 【Jue Niu thunder plough hot blade】
import scala.io.{
BufferedSource, Source}
object D02_ Read by character {
def main(args: Array[String]): Unit = {
read1()
// read2()
}
def read1(): Unit = {
val source: BufferedSource = Source.fromFile("./data/2.txt")
// Read... In characters
val iter: BufferedIterator[Char] = source.buffered
while (iter.hasNext) {
print(iter.next())
}
source.close()
}
def read2(): Unit = {
val source: BufferedSource = Source.fromFile("./data/2.txt")
// If the file is not large , You can read it directly into a string
val str: String = source.mkString
println(str)
source.close()
}
}
2.txt Content
Pavilion of Prince Teng Preface 【 author 】 Wang Bo 【 Dynasty 】Tengwang's Pavilion is near the river , Pei Yu Ming Luan stops singing and dancing .
Huadong faces Nanpu cloud , In the dusk of the Pearl curtain, the rain of the Western Hills rolls .
The shadow of the idle cloud pool is long , Things change for a few autumn .
Where is the emperor in the pavilion now ? Outside the sill, the Yangtze River flows by itself .
2.txt Location 
边栏推荐
- Qiniu cloud uploads video to get the first frame of video
- How to reduce the font size of custom controls (optimize the round dot progress bar)
- Applet opening traffic master
- Technologie des fenêtres coulissantes en octets dans la couche de transmission
- Text editor for QT project practice - Episode 10
- Realization of MNIST handwritten numeral recognition
- Wallpaper applet wechat applet
- Unimportant tokens can be stopped in advance! NVIDIA proposes an efficient visual transformer network a-vit with adaptive token to improve the throughput of the model
- redis + lua实现分布式接口限流实现方案
- Android SQLite database
猜你喜欢

Tiktok wallpaper applet v1.0.2 function, new arrival function

QT electronic clock

2022 simulated 100 questions of safety officer-c certificate examination and online simulated examination

Syntax highlighting of rich text

Text editor for QT project practice -- Episode 9

移动安全工具-jar

51 single chip microcomputer multi computer communication

【Redis实现秒杀业务④】一人一单,不可重复购买

Thermodynamic diagram display correlation matrix

2022r1 quick opening pressure vessel operation test questions and answers
随机推荐
A plug-in framework for implementing registration free and login verification with hook technology
The problem of multiple callback of video ads stimulated by applets (offcolse problem)
placeholder
Source code analysis the problem that fragments cannot be displayed in the custom ViewGroup
2022年危险化学品经营单位安全管理人员考试试题及模拟考试
[micro service sentinel] real time monitoring | RT | throughput | concurrency | QPS
Punch smart spirit 1. The brand is attractive. What is the strength of the product?
Thermodynamic diagram display correlation matrix
JS dynamically generates variable names and assigns values
Registration method of native method in JNI
2021-09-12
Databinding quick start (still using findviewbyid?)
Usage of assert
2022 melting welding and thermal cutting recurrent training question bank simulated examination platform operation
2022r1 quick opening pressure vessel operation test questions and answers
Garbage collection of C closure
【微服务|Sentinel】实时监控|RT|吞吐量|并发数|QPS
Input series
A small crawler program written by beginners
Examination questions and mock examination for safety management personnel of hazardous chemical business units in 2022