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

18 lines
469 B
Kotlin

package dev.inmo.kmppscriptbuilder.core.utils
import java.awt.Desktop
import java.net.URI
actual fun openLink(link: String): Boolean {
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
}