KotlinPublicationScriptsBui.../core/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/core/utils/openLink.kt

18 lines
469 B
Kotlin
Raw Normal View History

2022-11-15 12:53:59 +00:00
package dev.inmo.kmppscriptbuilder.core.utils
2021-03-02 11:19:17 +00:00
import java.awt.Desktop
import java.net.URI
2022-11-15 12:53:59 +00:00
actual fun openLink(link: String): Boolean {
2021-03-02 11:19:17 +00:00
val desktop = if (Desktop.isDesktopSupported()) Desktop.getDesktop() else null
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(URI(link))
return true
} catch (e: Exception) {
e.printStackTrace()
}
}
return false
}