PHP
·
发表于 5年以前
·
阅读量:8390
package com.ted.testcase
import android.text.TextUtils
import android.util.Log
import com.ted.android.utils.TedSDKLog
import com.ted.testcase.bean.Sms
import java.io.File
import java.io.InputStream
object DemoSmsLoader {
private const val TAG = "DemoSmsLoader"
private val sms: Sms? = null
fun loadSms(path: String): List<Sms>? {
var file = File(path)
if (!file.exists()) {
TedSDKLog.e(TAG, "样本 $path 不存在")
return null
}
val result: ArrayList<Sms> = ArrayList()
val inputStream: InputStream = File(path).inputStream()
inputStream.bufferedReader().useLines { lines ->
lines.forEach {
// TedSDKLog.d(TAG, "sms: $it")
if (TextUtils.isEmpty(it)) return@forEach
if (!it.contains("\t")) return@forEach
var array = it.split("\t")
if (TextUtils.isEmpty(array[1])) return@forEach
var sms = Sms(array[0], array[1])
result.add(sms)
// TedSDKLog.d(TAG, "adding sms $sms")
}
}
return result
}
}