The previous suggestion given me for this code, that
of performing the cast
byte [] dataArray = (byte [])dataStream.get(document);
still produces no return of bytes from my HWPFDocument.
How do I get a byte [] of the entire HWPFDocument,
assuming the following code?
/*
import java.io.*;
import java.nio.*;
import java.util.*;
import java.util.concurrent.*;
import org.apache.poi.*;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.poifs.storage.*;
//-------------------------------------------
import org.apache.poi.hwpf.*;
import org.apache.poi.hwpf.model.*;
import org.apache.poi.hwpf.model.io.*;
import org.apache.poi.hwpf.usermodel.*;
//-------------------------------------------
import org.apache.poi.hssf.usermodel .*;
//-------------------------------------------
import java.lang.reflect.*;
//-------------------------------------------
import javax.management.openmbean.*;
FileInputStream input = new FileInputStream(new File("demo.doc"));
POIFSFileSystem fileSystem = HWPFDocument.verifyAndBuildPOIFS(input);
HWPFDocument document = new HWPFDocument(fileSystem);
input.close();
Field dataStream = document.getClass().getDeclaredField("_dataStream");
dataStream.setAccessible(true);
System.out.println((dataStream.get(document)).getClass().getCanonicalName());
System.out.println();
byte [] dataArray = (byte [])dataStream.get(document);
ByteBuffer byteBuffer = ByteBuffer.wrap(dataArray);
dataArray = null;
dataArray = byteBuffer.array();
for (int i=0;i<dataArray.length;i++)
{
System.out.println(dataArray[i]);
}
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]