views:

249

answers:

1

this code reads contents of cell of excel file into a string

String theCell_00=rs.getCell(j,i).getContents();

is there any method using which the contents of excel cell are read as Java InputStream

i need to read excel cell content and pass the contents to InputStream argument of this function

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)
     {
     }
    }
+1  A: 

You can always wrap the string in a ByteArrayInputStream and pass it to your function:

encrypt(new ByteArrayInputStream(theCell_00.getBytes()), outputStream)
Nathan Voxland
thanks a lot worked fine
rover12