Skip to main content

Using DataHandlers

Once you've got the above done, its time to start writing your logic. DataHandlers are easy to use and create. To consume a DataHandler:

Picture picture = ...;
DataHandler handler = picture.getImageData();
InputStream is = handler.getInputStream();

There are many ways to create DataHandlers. You can use a FileDataSource, ByteArrayDataSource, or write your own DataSource:

DataSource source = new ByteArrayDataSource(new byte[] {...}, 
   "content/type");
DataSource source = new FileDataSource(new File("my/file"));

Picture picture = new Picture();
picture.setImageData(new DataHandler(source));

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!