当前位置:网站首页>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 
边栏推荐
- 2022年危险化学品经营单位安全管理人员考试试题及模拟考试
- 2022安全员-C证考试模拟100题及在线模拟考试
- Tiktok wallpaper applet, starlight wallpaper applet version 2.0, upgraded version
- Text editor for QT project practice -- Episode 9
- 2021-11-07
- How to quickly open traffic master for wechat applet
- [micro service sentinel] real time monitoring | RT | throughput | concurrency | QPS
- ros(24):error: invalid initialization of reference of type ‘xx’ from expression of type ‘xx’
- Meta & Berkeley proposed a universal multi-scale visual transformer based on pooled self attention mechanism. The classification accuracy in Imagenet reached 88.8%! Open source
- Go crawler framework -colly actual combat (IV) -- Zhihu answer crawl (I)
猜你喜欢

51 single chip microcomputer multi computer communication
![[micro service sentinel] real time monitoring | RT | throughput | concurrency | QPS](/img/fc/6b36759570b9b1007d2640009576d9.png)
[micro service sentinel] real time monitoring | RT | throughput | concurrency | QPS

Kubernetes 架构核心组件工作原理解析

I brush the question I - copy the linked list with random pointer

ServerSocket and socket connection

在企业级开发过程中我发现有位同事用select * from where 条件 for update

Registration method of native method in JNI

Text border format and text block of rich text

Mobile security tool jar

Go crawler framework -colly actual combat (III) -- panoramic cartoon picture capture and download
随机推荐
Sanic service startup failed
Virtual machine - network configuration
Text editor for QT project practice - Episode 12
2019 summary and 2020 outlook
2022年起重机司机(限桥式起重机)考试题库模拟考试平台操作
移动安全工具-apktool
Thermodynamic diagram display correlation matrix
Previous basic review (link)
Redis + Lua implementation of distributed interface current limiting
Punch smart spirit 1. The brand is attractive. What is the strength of the product?
Kubernetes 架构核心组件工作原理解析
Using tcp/udp tools to debug the yeelight ribbon
JSON file of China's provincial boundaries
Scala template method pattern
108 pages (40000 words) proposal for future apartment intelligent design platform project (version 2022)
Rich text tables, lists, pictures
传输层 以字节为单位的滑动窗口技术
JMeter socket connection sends data
Single blind box removal, social blind box and friend blind box program source code
Encryption and encoding resolution