Kotlin Commands
JVM and multiplatform language from JetBrains.All Kotlin pages
- gradle init --type kotlin-application: create a new Kotlin projectCreate a Kotlin/JVM project with gradle init --type kotlin-application --dsl kotlin: the options, the generated files, the wrapper, and running it with gradlew.
- kotlin convert string to int: toInt() vs toIntOrNull()Convert a String to an Int in Kotlin with toInt(), which throws NumberFormatException, or toIntOrNull(), which returns null. Radix, trimming, nullable pitfalls.
- kotlin read a file line by line (readLines, useLines, forEachLine)Read a file line by line in Kotlin with File.readLines(), forEachLine or useLines for large files. Encoding, line endings, closing the file and relative paths.
- kotlinc hello.kt -include-runtime -d hello.jar: compile and run Kotlin from the command lineCompile Kotlin on the command line with kotlinc hello.kt -include-runtime -d hello.jar, run it with java -jar. Library JARs, the HelloKt class name, pitfalls.