<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>IBM BPM Tips Q&amp;A - Recent questions tagged file</title>
<link>https://ibm.bpm.tips/tag/file</link>
<description>Powered by Dosvak LLC</description>
<item>
<title>how to read file from temp folder</title>
<link>https://ibm.bpm.tips/2990/how-to-read-file-from-temp-folder</link>
<description>&lt;p&gt;Hi, need suggestion how to read file from shared folder in ibm bpm server. i have create script to write file in service flow but there is no sample to read file from share folder.&lt;/p&gt;&lt;p&gt;//Below code converts the file content string in to byte[] (byte array).&lt;/p&gt;&lt;p&gt;var byteValue = Packages.java.lang.String(tw.local.ContentStream.content).getBytes();&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;// Below code, decodes the above Base64 byte array in to use format of byte[] (byte array)&lt;/p&gt;&lt;p&gt;var content64 = Packages.org.apache.commons.codec.binary.Base64.decodeBase64(byteValue);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;&lt;span style=&quot;white-space:pre&quot;&gt; &lt;/span&gt;var fileName=&quot;/opt/docs/&quot; + tw.local.ContentStream.fileName ;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var file = new Packages.java.io.File(fileName);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// if file doesnt exists, then create it&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!file.exists()) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file.createNewFile();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //change permission to 777 for all the users&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //no option for group and others file.setExecutable(true, false);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file.setReadable(true, false);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;file.setWritable(true, false);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var fop = new Packages.java.io.FileOutputStream(file);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fop.write(content64);&lt;br&gt;&lt;br&gt;Thank you,&lt;br&gt;&amp;nbsp;&lt;/p&gt;</description>
<category>Process Center</category>
<guid isPermaLink="true">https://ibm.bpm.tips/2990/how-to-read-file-from-temp-folder</guid>
<pubDate>Mon, 07 Dec 2020 07:10:44 +0000</pubDate>
</item>
</channel>
</rss>