01: /*
02: * Copyright 2004-2006 Fouad HAMDI.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: package org.csvbeans.parsers;
17:
18: import java.io.BufferedReader;
19: import java.io.IOException;
20: import java.io.InputStream;
21: import java.io.InputStreamReader;
22:
23: /**
24: * A reader for CSV files.
25: *
26: * @author Fouad Hamdi
27: * @since 0.5
28: */
29: public class InputStreamLinesReader implements LinesReader {
30: private BufferedReader reader;
31:
32: private InputStream is;
33:
34: public InputStreamLinesReader(InputStream is) {
35: reader = new BufferedReader(new InputStreamReader(is));
36: this .is = is;
37: }
38:
39: public InputStream getStream() {
40: return is;
41: }
42:
43: public InputStreamLinesReader(BufferedReader reader) {
44: this .reader = reader;
45: }
46:
47: /*
48: * (non-Javadoc)
49: *
50: * @see org.csvbeans.interfaces.LinesReader#nextLine()
51: */
52: public String nextLine() throws LinesReadingException {
53: try {
54: return reader.readLine();
55: } catch (IOException e) {
56: throw new LinesReadingException(e.getMessage(), e);
57: }
58: }
59: }
|