Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Explicit variable type

  • Loading branch information...
commit b6d7d9923abd0855975057a3fce78baabba601e0 1 parent 2a77eed
@rightgo09 authored
Showing with 14 additions and 0 deletions.
  1. +12 −0 03-06/TextCounter050.scala
  2. +2 −0  03-06/data.txt
View
12 03-06/TextCounter050.scala
@@ -0,0 +1,12 @@
+import scala.io.Source
+
+val filename: String = args(0)
+val src: Source = Source.fromFile(filename) // オブジェクトを取得
+var charCount: Int = 0
+var lineCount: Int = 0
+val lines: Iterator[String] = src.getLines
+for (line: String <- lines) {
+ charCount += line.length
+ lineCount += 1
+}
+println("文字数 = " + charCount + ", 行数 = " + lineCount)
View
2  03-06/data.txt
@@ -0,0 +1,2 @@
+Hello Wolrd
+Scala Programming Sample
Please sign in to comment.
Something went wrong with that request. Please try again.