0

I am reading a String from a file, and i need the default browser to open the link of that file. but it wants a final string as a parameter.

try
{
  Desktop.getDesktop().browse(new URL(URLs.get(i)).toURI());
} 
catch (URISyntaxException | IOException ex)
{
   ;
}

of course it does not work.. The Strings are in a ArrayList of String (URLs). any suggestions? thank you

  • Don't silently swallow your `Exception`(s); what error are you getting? What type of `String`(s) are you trying to open? – Elliott Frisch Apr 24 '16 at 18:37
  • Please [edit] your question and show a sample of the content of the file, also explain what you expect the browser to open for each of the values that you show. Also explain what you mean by "Of course it does not work". What happens? What did you expect to happen? – RealSkeptic Apr 24 '16 at 18:53
  • [Does this](http://stackoverflow.com/questions/874978/string-and-final) help? – Scott Forsythe Apr 24 '16 at 19:17
  • new URL("final String"), but i can only give it a String collected in a ArrayList of Strings. The error is that the parameter "URLs.get(i)" which is a string inside a ArrayList of Strings (copied from some files save in the pc), and so it says that the parameter must be a final string or a string with final characteristics –  Apr 26 '16 at 18:34
  • precisely "Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - local variables referenced from an inner class must be final or effectively final" –  Apr 26 '16 at 18:37

0 Answers0