Skip to content

Commit

Permalink
Fix a URI issue with spaces (illegal URI characters)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislo27 committed Sep 26, 2020
1 parent d0bbbf9 commit eeab317
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import java.io.File
import java.net.URI


fun Net.openFileExplorer(absPath: String): Boolean {
fun Net.openFileExplorer(uri: URI): Boolean {
return try {
Desktop.getDesktop().browse(URI("file:///${absPath.replace("\\", "/")}"))
Desktop.getDesktop().browse(uri)
true
} catch (t: Throwable) {
t.printStackTrace()
false
}
}

fun Net.openFileExplorer(file: File): Boolean = openFileExplorer(file.absolutePath)
fun Net.openFileExplorer(file: File): Boolean = openFileExplorer(file.toURI())

fun Net.openFileExplorer(fileHandle: FileHandle): Boolean = openFileExplorer(fileHandle.file())

0 comments on commit eeab317

Please sign in to comment.