此代码将excel文件的单元格内容读入字符串
String theCell_00=rs.getCell(j,i).getContents();
是否有任何方法可以将excel单元格的内容读取为Java InputStream
我需要读取excel单元格内容并将内容传递给此函数的InputStream参数
public void encrypt(InputStream in, OutputStream out)
{
try
{
// Bytes written to out will be encrypted
out = new CipherOutputStream(out, ecipher);
// Read in the cleartext bytes and write to out to encrypt
int numRead = 0;
while ((numRead = in.read(buf)) >= 0)
{
out.write(buf, 0, numRead);
}
out.close();
}
catch (java.io.IOException e)
{
}
}
答案 0 :(得分:1)
您始终可以将字符串包装在ByteArrayInputStream中并将其传递给您的函数:
encrypt(new ByteArrayInputStream(theCell_00.getBytes()), outputStream)