It's all about the answers!

Ask a question

Adding a binary file using Java API

K M (38325151) | asked Jul 21 '10, 9:27 a.m.
I have an example of adding a text file

VersionedContentManagerByteArrayInputStreamPovider inputStream = new VersionedContentManagerByteArrayInputStreamPovider("hello".getBytes());

IFileContent storedContent = contentManager.storeContent(IFileContent.ENCODING_US_ASCII,FileLineDelimiter.LINE_DELIMITER_PLATFORM, inputStream, null, MONITOR);

Does anybody have an example of adding a binary file????

3 answers

permanent link
K M (38325151) | answered Jul 22 '10, 12:35 p.m.
StringBuffer tmp_buf = new StringBuffer("");

VersionedContentManagerByteArrayInputStreamPovider inputStream =
new VersionedContentManagerByteArrayInputStreamPovider

IFileContent storedContent = contentManager.storeContent
,FileLineDelimiter.LINE_DELIMITER_NONE, inputStream, null, MONITOR);

permanent link
K M (38325151) | answered Jul 22 '10, 2:38 p.m.
There must be a better way??

permanent link
K M (38325151) | answered Jul 23 '10, 10:15 a.m.
fileStream = new FileInputStream(filename);
final DisposableInputStreamProvider isProvider = TemporaryOutputStream.createLocalBuffer(fileStream,MONITOR);
IFileContent storedContent = contentManager.storeContent(IFileContent.ENCODING_UTF_8,FileLineDelimiter.LINE_DELIMITER_NONE,
new AbstractVersionedContentManagerInputStreamProvider() {
public void dispose() throws IOException,
TeamRepositoryException {

public InputStream getInputStream(int flags)
throws IOException, TeamRepositoryException {
//it's ok to pass in null, we know the content is cached on local disk
return isProvider.getInputStream(null);

public InputStream wrapInputStream(InputStream in)
throws IOException, TeamRepositoryException {
return in;

, null, MONITOR);

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.