1 package org.jahia.services.fileextraction; 2 3 import java.io.IOException ; 4 import java.io.InputStream ; 5 import java.io.InputStreamReader ; 6 7 import org.jahia.utils.FileUtils; 8 9 10 21 22 public class TextExtractor implements FileExtractor { 23 24 public TextExtractor(){ 25 } 26 27 35 public ExtractedDocument getExtractedDocument( 36 String path, 37 long lastModified, 38 InputStream fileStream) 39 throws Exception { 40 return getExtractedDocument(path,lastModified,fileStream,null); 41 } 42 43 52 public ExtractedDocument getExtractedDocument( 53 String path, 54 long lastModified, 55 InputStream fileStream, 56 String charSet) 57 throws Exception { 58 ExtractedDocumentImpl extDoc = new ExtractedDocumentImpl(); 59 extDoc.setContent(this.getContentAsString(path,lastModified,fileStream,charSet)); 60 return extDoc; 61 } 62 63 73 public String getContentAsString(String path, long lastModified, 74 InputStream fileStream) 75 throws IOException { 76 return getContentAsString(path, lastModified, fileStream, null); 77 } 78 79 90 public String getContentAsString(String path, long lastModified, 91 InputStream fileStream, String charSet) 92 throws IOException { 93 InputStreamReader reader = null; 94 if ( charSet != null ){ 95 reader = new InputStreamReader (fileStream, charSet); 96 } else { 97 reader = new InputStreamReader (fileStream); 98 } 99 return FileUtils.readerToString(reader); 100 } 101 } 102 | Popular Tags |