Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Adding a binary file using Java API

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????

0 votes



3 answers

Permanent link
StringBuffer tmp_buf = new StringBuffer("");



VersionedContentManagerByteArrayInputStreamPovider inputStream =
new VersionedContentManagerByteArrayInputStreamPovider
(tmp_buf.toString().getBytes(IContent.ENCODING_UTF_8),
0,tmp_buf.length());

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

0 votes


Permanent link
There must be a better way??

0 votes


Permanent link
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() {
@Override
public void dispose() throws IOException,
TeamRepositoryException {
isProvider.dispose();
}

@Override
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);
}

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


}
, null, MONITOR);

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,939

Question asked: Jul 21 '10, 9:27 a.m.

Question was seen: 6,051 times

Last updated: Jul 21 '10, 9:27 a.m.

Confirmation Cancel Confirm