Scala code in one day (9) and scala code in one day

Source: Internet
Author: User

Scala code in one day (9) and scala code in one day
Scala code in one day (9)
To better control spark, I recently studied scala language features, mainly reading "quick learning scala" and writing down some codes that I think are useful.

Package examplesimport scala. io. sourceobject Example9 extends App {val source = Source. fromFile ("/home/linger/data/hive_data", "UTF-8") val lines = source. getLines () for (l <-lines) {println (l)} lines. toArray source. mkString source. close () // you can call some Java io libraries to process files. // The regular expression val wsnumws = "" \ s [0-9] + \ s + """. r // The original string format val wsnumws2 = "\ s [0-9] + \ s + ". r // equivalent to above, but need to be transferred // regular Extraction Machine val numitem = "([0-9] +) ([a-z] + )". r val numitem (num, item) = "99 bottle" println (num, item )}


Author: linger link: http://blog.csdn.net/lingerlanlan/article/details/43970979

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.