Last active
October 14, 2016 09:50
-
-
Save mocyuto/11585376f4741f535365b69d49fdba8f to your computer and use it in GitHub Desktop.
inputStream to Seq[String]
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
import java.io.{ BufferedReader, InputStream, InputStreamReader } | |
object Input{ | |
/** | |
* inputStreamで取得したものをカラム数だけ取得 | |
* @return (String列, 途中で切ったか) | |
*/ | |
protected def stream2string(csvStream: InputStream, lineNumberOp: Option[Int]): (Seq[String], Boolean) = { | |
val reader = new BufferedReader(new InputStreamReader(csvStream)) | |
var count = -1 | |
val a = Iterator.continually(reader.readLine()).takeWhile { r => | |
count += 1 | |
lineNumberOp.forall(_ >= count) | |
}.toSeq | |
a.init.filterNot(_ == null) -> (a.last != null) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment