当前位置:网站首页>Scala IO reads by lexical units and numbers
Scala IO reads by lexical units and numbers
2022-06-25 01:03:00 【Jue Niu thunder plough hot blade】
import scala.io.Source
// The so-called lexical units refer to strings separated by specific symbols ,
// If the data in the data source file is a number in string form ,
// We can easily get these data directly from the file
object D03_ Read by lexical units and numbers {
def main(args: Array[String]): Unit = {
val source = Source.fromFile("./data/3.txt")
val str = source.mkString
// Cut according to blank characters
/** * \s For white space characters , That is, the space 、\t、\n、\r etc. * +: Quantifier , That is, the previous content appears at least once */
val strArr: Array[String] = str.split("\\s+")
// Convert a string array to int An array of types
val intArr: Array[Int] = strArr.map(_.toInt)
for (num <- intArr) print((num + 1) + " ")
source.close()
}
}
3.txt Content
10 2 5
11 2
5 3 9 7
3.txt Location 
边栏推荐
- Hot fix sophix multi-channel patch solution
- VNC viewer remote connection raspberry pie without display
- Mobile security tool apktool
- Android SQLite database
- Databinding quick start (still using findviewbyid?)
- I'd like to ask how to open an account at industrial securities? Is it safe to open a stock account through the link
- Tiktok wallpaper applet, starlight wallpaper applet version 2.0, upgraded version
- Go crawler framework -colly actual combat (III) -- panoramic cartoon picture capture and download
- Uniapp encapsulated incentive advertisement, screen insert advertisement and banner advertisement
- Solution to network access packet loss of Tencent cloud international ECS
猜你喜欢

The acceleration of 100 km is only 5.92 seconds, and the willanda high-performance version leads with the strength of high-energy products

I 刷题 I — 复制带随机指针的链表

108 pages (40000 words) proposal for future apartment intelligent design platform project (version 2022)

The interview questions and answers for the high-frequency software test of Dachang help you prepare for the golden nine silver ten

Registration method of native method in JNI

2022安全员-C证考试模拟100题及在线模拟考试

Encryption and encoding resolution

Network request -volley

2022年起重机司机(限桥式起重机)考试题库模拟考试平台操作

Use of navigation and navigationui
随机推荐
The problem of multiple callback of video ads stimulated by applets (offcolse problem)
Single blind box removal, social blind box and friend blind box program source code
Working principle analysis of kubernetes architecture core components
2022年起重机司机(限桥式起重机)考试题库模拟考试平台操作
Infotnews | is the development of domestic NFT limited to digital collections?
Several ways for wechat applet to jump to the page are worth collecting
EVM Brief
Only positive integers can be entered in the text box
2021-09-12
Text editor for QT project practice - Episode 12
Scala classes inherit multiple attributes
The basic principle and application of iterator and enhanced for
108页(4万字)未来公寓智能化设计平台项目方案建议书2022版
Apk decompiled method (not confused)
智能合约安全审计入门篇 —— delegatecall (2)
Garbage collection of C closure
腾讯云国际云服务器网络访问丢包问题解决办法
Network request -volley
adb shell getevent
Input series