Monday, 15 September 2014

java - Why use getResourceAsStream when loading images? -


Assume that I am creating a jar file and there is an icon in the asset folder that enters the jar.

Then before using, stage.getIcons (). Add (icon); There is a special benefit or loss to be in the form of an icon in my code

  image icon = new image ("Assets / Icon.png");  

versus GetResourceAsStream ("Property / Icon" "));

Both work well, So I have to find out which side I should generally move towards and why.

There is a related topic but it is more than loading styles with web applications

< P s contextClassLoader Code> including code> string value.

is class # getResourceAsString Have you already decided for the class, which is slightly faster, but less likely to be ambiguous and possibly : It can be easy to diagnose that you have problems (as you control the source system themselves, the image) and are not deciding to leave the code which you do not immediately control (and since validateUrl is private place , can not be changed)


No comments:

Post a Comment