java - What is difference between these two kinds of image loading code? -


these 2 kinds of code below used loading image file:

a)

file sourceimage = new file("filename"); image image = imageio.read(sourceimage); 

b)

toolkit tk = toolkit.getdeafaulttoolkit(); img=tk.getimage("filename"); 

what's real difference between these 2 codes ?

imageio.read(file) takes file , newer toolkit.getimage(string) takes filename (and has been part of language longer). also, first 1 provides additional functionality (that is, imageio.read(file) javadoc says in part)

the current cache settings getusecache , getcachedirectory used control caching in imageinputstream created.

note there no read method takes filename string; use method instead after creating file filename.


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -