aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2011-03-30 11:34:12 +0000
committerNick Burch <nick@apache.org>2011-03-30 11:34:12 +0000
commitfd5b4a4e4f76c2b8025032947d81355bc9c73db8 (patch)
treea37d347c5e73de57557c33021c7c7ec0663ace04 /src/ooxml/java
parent5c4ed6e2750c6a6eab5f32efeefb4df58399befc (diff)
downloadpoi-fd5b4a4e4f76c2b8025032947d81355bc9c73db8.tar.gz
poi-fd5b4a4e4f76c2b8025032947d81355bc9c73db8.zip
Implement the load method on MemoryPackagePart
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1086909 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java')
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java
index 0d7f8d39c1..f950e2ca3b 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/MemoryPackagePart.java
@@ -18,6 +18,8 @@
package org.apache.poi.openxml4j.opc.internal;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -27,6 +29,7 @@ import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.internal.marshallers.ZipPartMarshaller;
+import org.apache.poi.util.IOUtils;
/**
* Memory version of a package part. Use to
@@ -111,7 +114,20 @@ public final class MemoryPackagePart extends PackagePart {
@Override
public boolean load(InputStream ios) throws InvalidFormatException {
- throw new InvalidFormatException("Method not implemented");
+ // Grab the data
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ IOUtils.copy(ios, baos);
+ } catch(IOException e) {
+ throw new InvalidFormatException(e.getMessage());
+ }
+
+ // Save it
+ data = baos.toByteArray();
+ length = data.length;
+
+ // All done
+ return true;
}
@Override