2009-11-21 63 views
0

這個代碼讀取的excel細胞文件轉換成字符串讀取Excel單元內容的Java的InputStream

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

爲什麼?你在使用哪種API? – 2009-11-21 06:44:40

+0

編輯與更多信息 – rover12 2009-11-21 06:51:43

回答

1

您可以隨時換行字符串中一個ByteArrayInputStream,並將其傳遞到你的功能:

encrypt(new ByteArrayInputStream(theCell_00.getBytes()), outputStream) 
+0

感謝很多工作正常 – rover12 2009-11-21 07:48:15