1 /**
2 *
3 * Copyright 2003-2005 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.geronimo.javamail.store.nntp.newsrc;
19
20 import java.io.BufferedReader;
21 import java.io.File;
22 import java.io.FileInputStream;
23 import java.io.FileOutputStream;
24 import java.io.IOException;
25 import java.io.InputStreamReader;
26 import java.io.OutputStreamWriter;
27 import java.io.Writer;
28
29 public class NNTPNewsrcFile extends NNTPNewsrc {
30
31 File source;
32
33 /**
34 * Construct a NNTPNewsrc object that is targetted at a file-based backing
35 * store.
36 *
37 * @param source
38 * The source File for the .newsrc data.
39 */
40 public NNTPNewsrcFile(File source) {
41 this.source = source;
42 }
43
44 /**
45 * Retrieve an input reader for loading the newsrc file.
46 *
47 * @return A BufferedReader object for reading from the newsrc file.
48 * @exception IOException
49 */
50 public BufferedReader getInputReader() throws IOException {
51 return new BufferedReader(new InputStreamReader(new FileInputStream(source)));
52 }
53
54 /**
55 * Obtain a writer for saving a newsrc file.
56 *
57 * @return The output writer targetted to the newsrc file.
58 * @exception IOException
59 */
60 public Writer getOutputWriter() throws IOException {
61
62 return new OutputStreamWriter(new FileOutputStream(source, false));
63 }
64 }