Issue
I am getting this error:
Caused by: java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\Users\Emre\Desktop\PN1g1z.gif
And I really don't get what's wrong.
This is what throws the exception:
Media media = new Media(file.getAbsolutePath());
Solution
Media
expects an URI as String in the constructor. So, instead of using File#getAbsolutePath()
, you should be using File#toURI()
instead.
https://docs.oracle.com/javase/7/docs/api/java/io/File.html#toURI%28%29
From the Media#new
JavaDoc (thanks @Andreas):
source - The URI of the source media.
Answered By - jpkrohling
Answer Checked By - Senaida (JavaFixing Volunteer)