Home Segments Top Top Previous Next

841: Mainline

You can access image files in much the same way as you access text files. The only difference is that you cast the value returned by getContent into an ImageProducer instance, rather than into an input stream:

URL url = MovieAuxiliaries.class.getResource(fileName);                  
ImageProducer producer = (ImageProducer) (url.getContent()); 

The getContent method has the intelligence required to deal with both text and image files, as well as with audio files, using both file extensions and file content as a guide.