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:

  • One, the explorer show an error that it can´t read the file, example: a jpg or a word file..
  • Two, if the path have a blank like: "my picture.jpg" recognize everything after the blank as a normal text...

can someone give me a Tipp, How to fix that, or I just using the wrong method?

Was it helpful?

Solution

You can use toURI() method that turns the file path into a URI:

file.getAbsoluteFile().toURI().toString()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top