• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to implement an interface?

 
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In javax.activation package there is an implementation of DataSource called FileDataSource. One can use it to construct a DataSource from a File:
DataSource source = new FileDataSource(filename);
How can I implement DataSource so that I can construct a DataSource from an inputStream ? Any clues or examples? How do I approach this?
Thanks.
Bruce
Javax.activation doc: http://java.sun.com/products/javabeans/glasgow/javadocs/javax/activation/package-summary.html
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since the only concrete classes provided in the implementation are FileDataSource, URLDataSource, if you want something different, you'll need to write your own implementation.
public class MyDataSource implements DataSource{...}
It appears as if the class doesn't need to be anything fancy, there are just 4 methods that need to be provided, and they all appear to be just accessors.
David

------------------
David Kane
david_kane@houseofyin.com
Author of Software Architecture: Organizational Principles and Patterns
http://www.vraps.com
http://www.houseofyin.com
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks David;
I am trying to implement DataSource interface. I found a sample in JavaMail Download.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic