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