KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > utils > fileparsers > TextExtractor


1 package org.jahia.utils.fileparsers;
2
3 import java.io.IOException JavaDoc;
4 import java.io.InputStream JavaDoc;
5 import java.io.InputStreamReader JavaDoc;
6 import org.jahia.utils.FileUtils;
7
8
9 /**
10  * <p>Title: HDF Text content extractor file</p>
11  * <p>Description: This classes uses Jakarta's POI library to extract content
12  * from HDF formatted files. Some of the code in this class is not used
13  * currently but might be needed to process other types of files based on
14  * the POI File system.</p>
15  * <p>Copyright: Copyright (c) 2003</p>
16  * <p>Company: Jahia Ltd</p>
17  * @author Serge Huber
18  * @version 1.0
19  */

20
21 public class TextExtractor implements FileExtractor {
22
23     public TextExtractor(){
24     }
25
26     /**
27      * This method returns all the text of an HDF file.
28      *
29      * @param path String
30      * @param lastModified long
31      * @param fileStream InputStream
32      * @throws IOException thrown if there was an error while parsing the
33      * file format, notably if the file is an RTF file instead of a HDF file.
34      * @return String
35      */

36     public String JavaDoc getContentAsString(String JavaDoc path, long lastModified,
37                                      InputStream JavaDoc fileStream)
38     throws IOException JavaDoc {
39         return getContentAsString(path, lastModified, fileStream, null);
40     }
41
42     /**
43      * This method returns all the text of an HDF file.
44      *
45      * @param path String
46      * @param lastModified long
47      * @param fileStream InputStream
48      * @param charSet String
49      * @throws IOException thrown if there was an error while parsing the
50      * file format, notably if the file is an RTF file instead of a HDF file.
51      * @return String
52      */

53     public String JavaDoc getContentAsString(String JavaDoc path, long lastModified,
54                                      InputStream JavaDoc fileStream, String JavaDoc charSet)
55     throws IOException JavaDoc {
56         InputStreamReader JavaDoc reader = null;
57         if ( charSet != null ){
58             reader = new InputStreamReader JavaDoc(fileStream, charSet);
59         } else {
60             reader = new InputStreamReader JavaDoc(fileStream);
61         }
62         return FileUtils.readerToString(reader);
63     }
64 }
65
Popular Tags