You can use toURI()
method that turns the file path into a URI:
file.getAbsoluteFile().toURI().toString()
Question
I´m writing some Java and one of my task is to convert the Input/Output in to html. Well everything is going good, I can read some files and get the path of those files. Now I´m trying to convert the path in to a normal link so:
"<a href=" + file.getAbsolutePath() + " target=_parent>"
Works pretty good, but:
can someone give me a Tipp, How to fix that, or I just using the wrong method?
Solution
You can use toURI()
method that turns the file path into a URI:
file.getAbsoluteFile().toURI().toString()