KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > core > io > InputStreamSource


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.core.io;
18
19 import java.io.IOException JavaDoc;
20 import java.io.InputStream JavaDoc;
21
22 /**
23  * Simple interface for objects that are sources for a <code>java.io.InputStream</code>.
24  * Base interface for Spring's more extensive Resource interface.
25  *
26  * <p>Useful as an abstract content source for mail attachments, for example.
27  * Spring's ByteArrayResource or any file-based Resource implementation can be used
28  * as concrete instance, allowing to read the underlying content stream multiple times.
29  * For single-use streams, InputStreamResource can be used for any given InputStream.
30  *
31  * @author Juergen Hoeller
32  * @since 20.01.2004
33  * @see java.io.InputStream
34  * @see Resource
35  * @see InputStreamResource
36  * @see ByteArrayResource
37  */

38 public interface InputStreamSource {
39
40     /**
41      * Return an InputStream.
42      * It is expected that each call creates a <i>fresh</i> stream.
43      * <p>For creating mail attachments, note that JavaMail needs to be able to
44      * read the stream multiple times. For such a use case, it is <i>required</i>
45      * that each <code>getInputStream()</code> call returns a fresh stream.
46      * @throws IOException if the stream could not be opened
47      * @see org.springframework.mail.javamail.MimeMessageHelper#addAttachment(String, InputStreamSource)
48      */

49     InputStream JavaDoc getInputStream() throws IOException JavaDoc;
50
51 }
52
Popular Tags