0

此代码将 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)
        {
        }
    }
4

1 回答 1

1

您始终可以将字符串包装在 ByteArrayInputStream 中并将其传递给您的函数:

encrypt(new ByteArrayInputStream(theCell_00.getBytes()), outputStream)
于 2009-11-21T06:53:49.803 回答