標準入力からのデータ読み込みのテスト用のScalaのプログラム。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.pandanote.utf8stdintest | |
// See https://pandanote.info/?p=5265 for details. | |
import java.io.BufferedInputStream | |
import scala.io.Source | |
import scala.io.Codec | |
import scala.util.matching.Regex | |
import java.nio.charset.{Charset,CodingErrorAction} | |
import java.io.BufferedReader | |
import java.io.InputStreamReader | |
object UTF8StdinTest { | |
val mm = """(\S+) (\S+) (\S+)""".r | |
def main(args: Array[String]) = { | |
Source.fromInputStream(System.in)("UTF-8").getLines.foreach(l => l match { | |
case mm(date,section,fare) => println(date+":"+section+":"+fare) | |
case x => println("その他") | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment