문제

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?

도움이 되었습니까?

해결책

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

file.getAbsoluteFile().toURI().toString()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top