1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.mail.internet;
  6. import java.io.*;
  7. /**
  8. * An InputStream that is backed by data that can be shared by multiple
  9. * readers may implement this interface. This allows users of such an
  10. * InputStream to determine the current positionin the InputStream, and
  11. * to create new InputStreams representing a subset of the data in the
  12. * original InputStream. The new InputStream will access the same
  13. * underlying data as the original, without copying the data.
  14. *
  15. * @version 1.1, 00/09/18
  16. * @author Bill Shannon
  17. * @since JavaMail 1.2
  18. */
  19. public interface SharedInputStream {
  20. /**
  21. * Return the current position in the InputStream, as an
  22. * offset from the beginning of the InputStream.
  23. *
  24. * @return the current position
  25. */
  26. public long getPosition();
  27. /**
  28. * Return a new InputStream representing a subset of the data
  29. * from this InputStream, starting at <code>start</code> (inclusive)
  30. * up to <code>end</code> (exclusive). <code>start</code> must be
  31. * non-negative. If <code>end</code> is -1, the new stream ends
  32. * at the same place as this stream. The returned InputStream
  33. * will also implement the SharedInputStream interface.
  34. *
  35. * @param start the starting position
  36. * @param end the ending position + 1
  37. * @return the new stream
  38. */
  39. public InputStream newStream(long start, long end);
  40. }