JUST PLAYING AROUND

This commit is contained in:
Johannes Mockenhaupt 2019-04-10 14:50:26 +02:00
parent 85cc61934c
commit a33afc99f6
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -24,16 +24,12 @@ fun isConnected(): Boolean {
// convert inputstream to String
@Throws(IOException::class)
fun InputStream.findVersion(): String? {
var version: String? = null
val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)"
this.bufferedReader().forEachLine {
if (regex.toRegex().matches(it)) {
version = regex.toRegex().matchEntire(it)?.groupValues?.getOrNull(3)
return@forEachLine
}
}
return version
val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)".toRegex()
return bufferedReader()
.readLines()
.filter { regex.matches(it) }
.mapNotNull { regex.matchEntire(it)?.groupValues?.getOrNull(3) }
.firstOrNull()
}
private val log = LoggerFactory.getLogger(L.CORE)