Reading Teamsite files (CSSimpleFile) from the CSSDK

Posted: 12 November 2009 in CSSDK, Java

CSSimpleFile provides an input stream to access the content of the file. Here’s a utility to read the content from the files, both as text and as binary content:

package piquet;

import com.interwoven.cssdk.common.CSException;
import com.interwoven.cssdk.filesys.CSSimpleFile;

 * @author piquetl
public class CSSimpleFileReader {

 public static String read(CSSimpleFile simpleFile) throws IOException, CSException {
     byte[] fileContent=readBytes(simpleFile);
     return new String(fileContent, "utf-8");

 public static byte[] readBytes(CSSimpleFile simpleFile) throws IOException, CSException {
 if (simpleFile == null) {
     throw new IllegalStateException("Cannot read null file.");
 if (((int) simpleFile.getSize()) > Integer.MAX_VALUE) {
 throw new IOException("File is too large");

 byte[] bytes = new byte[(int) simpleFile.getSize()];
 int offset = 0;
 int bytesRead = 0;
 InputStream inputStream = simpleFile.getInputStream(true);
 while (offset < bytes.length && (bytesRead =, offset, bytes.length - offset)) >= 0) {
 offset += bytesRead;
 return (bytes);
  1. tim says:

    I have the vpath to a file in teamsite that I’d like to set a CSSimpleFile instance to that file. How can I accomplish this? Also, where is all the documentation (javadoc) for the cssdk located?

  2. the cssdk javadocs are in the $IW_HOME folder. look for cssdk_doc.jar.

  3. rhomielijah says:

    This is exactly what I have been looking for. Keep up the good work. Thank you very much for this share.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s