Skip to content

Utility functions for kotlin programing language

Notifications You must be signed in to change notification settings

MaaxGr/KotlinUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BashUtil

Install via Gradle

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.MaaxGr:KotlinUtils:1.2.0'
}

Code Examples

BashUtil.executeCommand()

  • Execute a bash command
  • Possibility to handle each output line
  • Possibility to handle complete output result.
  • No Deadlock => executeCommand() can handle huge output
val result = BashUtil.executeCommand("echo 'Hello World'") { line ->
    // handle read line. e.g. print it out
    println(line)
}

// result is the complete output string
println(result)

MRegex

  • findFirst(input: String) find first match for input on regex
  • findAll(input: String) find all matches for input on regex
val regex = MRegex("http:\\/\\/([a-z0-9-\\.]+):(\\d+)")
val analze = regex.findFirst("http://my.test.com:3128")

if (analze is FindFirstResult.SingleMatch) {
    val (hostname: String, port: String) = analze.groups
    println("Host: $hostname; Port $port")
}

StringExtensions

  • camelToSnakeCase()
  • snakeToUpperCamelCase()
  • snakeToLowerCamelCase()

About

Utility functions for kotlin programing language

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages