Contents are not readable after programmatically delivering files to stream.
Dashrath Kale (154●27●23)
| asked Jul 24 '13, 5:30 a.m.
retagged Aug 14 '13, 12:54 p.m. by Te-Hsin Shih (285●4) I can deliver file to the stream under component but the contents are not getting in readable format and some files getting blank. We checked this by using UTF-8 encoding but facing the same issue. I we covert a String into byte array like. ( new VersionedContentManagerByteArrayInputStreamPovider("my file contentst".getBytes()), null, monitor); ). then we can read the contents from the repository files.
With the following code I trying to deliver the files but contents are not readable.
File testFile= new File( "C:/testFile.txt");
byte[] byteArray = new byte[(int) testFile.length()];
IFileItem file = (IFileItem) IFileItem.ITEM_TYPE.createItem(); file.setName(testFile.getName()); file.setParent(applicationFolder); IFileContentManager contentManager = FileSystemCore .getContentManager(repo); IFileContent storedContent = contentManager.storeContent( IFileContent.ENCODING_US_ASCII, FileLineDelimiter.LINE_DELIMITER_PLATFORM, new VersionedContentManagerByteArrayInputStreamPovider(byteArray), null, monitor); file.setContentType(IFileItem.CONTENT_TYPE_TEXT); file.setContent(storedContent); file.setFileTimestamp(new Date()); workspace.commit(cs1, Collections.singletonList(workspace .configurationOpFactory().save(file)), monitor);
|
One answer
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.