cancel
Showing results for 
Search instead for 
Did you mean: 

Writing information from a StringBuffer into a text file in KM

Former Member
0 Kudos

Hello All,

Is there a way to write content such as a text file into the KM.

The only way I can see at this point is:

1. create a resource

2. transfer stringBuffer into an inputStream

3. Update the resource with the inputStream

This feels awkward and I have not tried it yet. Basically I want to write reports into a KM directory.

Points awarded to helpful answers. Thanks!

Cory

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

createResource always takes InputStreams. Why is that a problem? Just use string.toBytes(encoding) and ByteArrayInputStream to obtain a stream for that.

Just be sure that you're consistent in the character encodings you use when obtaining the byte array from the string (UTF-8 recommended) and when creating the Content object.

Best regards, Julian

Former Member
0 Kudos

Thanks Julian,

Not so much a problem but extra complexity that would have been nice to see encapsulated in the API

Just thought I would ask. I will give it a try today.

Cory