我有以下情况,变成我有的方法:
ByteArrayInputStream fis = new ByteArrayInputStream(Bean.getValoreString("PDFmulti", "PDF").getBytes());
如您所见, fis varialbe 是一个ByteArrayInputStream和Bean.getValoreString("PDFmulti", "PDF").getBytes()返回一个 byte[]
所以现在我需要使用 iText 将fis对象的内容放入 PDF 中。
我能做些什么呢?我认为我必须读取此输入流并将其内容放入ByteArrayOutputStream,如下所示:
public static byte[] readFully(InputStream stream) throws IOException
{
byte[] buffer = new byte[8192];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int bytesRead;
while ((bytesRead = stream.read(buffer)) != -1)
{
baos.write(buffer, 0, bytesRead);
}
return baos.toByteArray();
}
但是之后?