aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/mammoth/DocumentConverter.java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-03-25 11:18:02 +0000
committerMichael Williamson <mike@zwobble.org>2016-03-25 11:18:02 +0000
commitb9ccb58ba0e6c0557d18f45a52a6a216177dbd56 (patch)
treef989282769cb2e2535bb63f183d7acc797221d8c /src/main/java/org/zwobble/mammoth/DocumentConverter.java
parentde4c76d2eca62b38b0d84e3292a3fd343ff378ca (diff)
Add extractRawText for streams, as documented
Diffstat (limited to 'src/main/java/org/zwobble/mammoth/DocumentConverter.java')
-rw-r--r--src/main/java/org/zwobble/mammoth/DocumentConverter.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main/java/org/zwobble/mammoth/DocumentConverter.java b/src/main/java/org/zwobble/mammoth/DocumentConverter.java
index 557adc6..94fb09c 100644
--- a/src/main/java/org/zwobble/mammoth/DocumentConverter.java
+++ b/src/main/java/org/zwobble/mammoth/DocumentConverter.java
@@ -96,10 +96,24 @@ public class DocumentConverter {
* This will ignore all formatting in the document.
* Each paragraph is followed by two newlines.
*/
+ public Result<String> extractRawText(InputStream stream) throws IOException {
+ return withDocxFile(stream, zipFile ->
+ extractRawText(Optional.empty(), zipFile));
+ }
+
+ /**
+ * Extract the raw text of the document.
+ * This will ignore all formatting in the document.
+ * Each paragraph is followed by two newlines.
+ */
public Result<String> extractRawText(File file) throws IOException {
return withDocxFile(file, zipFile ->
- readDocument(Optional.of(file.toPath()), zipFile)
- .map(DocumentConverter::extractRawTextOfChildren));
+ extractRawText(Optional.of(file.toPath()), zipFile));
+ }
+
+ private InternalResult<String> extractRawText(Optional<Path> path, DocxFile zipFile) {
+ return readDocument(path, zipFile)
+ .map(DocumentConverter::extractRawTextOfChildren);
}
private static <T> T withDocxFile(File file, Function<DocxFile, T> function) throws IOException {