标签:
def
parseCSV(csv
:
String)
=
{
try
{
Some {
csv.split(
"\n"
).map { line
=
>
val
tokens
=
line.split(
";"
)
ActivityData(tokens(
0
).toLong, tokens(
1
).toInt, tokens(
2
).toInt, tokens(
3
).toLong)
}
}
}
catch
{
case
_
:
Throwable
=
> None
}
}
def
parseCSV(csv
:
String)
=
Try {
csv.split(
"\n"
).map { line
=
>
val
tokens
=
line.split(
";"
)
ActivityData(tokens(
0
).toLong, tokens(
1
).toInt, tokens(
2
).toInt, tokens(
3
).toLong)
}
}
parseCSV(csvdata).map { entries
=
>
//do something with the data
}.getOrElse {
BadRequest(
"Invalid CSV Data"
)
//this is Play Framework specific (returns a 400 HTTP response with a message)
}
标签:
原文地址:http://www.cnblogs.com/xinsheng/p/4470103.html