<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to use tJava to read the contents of a file in Data Movement &amp; Streaming</title>
    <link>https://community.qlik.com/t5/Data-Movement-Streaming/How-to-use-tJava-to-read-the-contents-of-a-file/m-p/2444060#M2156</link>
    <description>&lt;P&gt;I ended up asking an AI for the answer and it gave it to me.&amp;nbsp; So some sample java code to read a file would look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="language-java"&gt;&lt;SPAN class="hljs-comment"&gt;// Specify the path to your file&lt;/SPAN&gt;
&lt;SPAN class="hljs-type"&gt;String&lt;/SPAN&gt; &lt;SPAN class="hljs-variable"&gt;filePath&lt;/SPAN&gt; &lt;SPAN class="hljs-operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="hljs-string"&gt;"C:\\path\\to\\your\\file.txt"&lt;/SPAN&gt;;

&lt;SPAN class="hljs-keyword"&gt;try&lt;/SPAN&gt; {
    java.io.&lt;SPAN class="hljs-type"&gt;BufferedReader&lt;/SPAN&gt; &lt;SPAN class="hljs-variable"&gt;reader&lt;/SPAN&gt; &lt;SPAN class="hljs-operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; &lt;SPAN class="hljs-title class_"&gt;java&lt;/SPAN&gt;.io.BufferedReader(&lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; &lt;SPAN class="hljs-title class_"&gt;java&lt;/SPAN&gt;.io.FileReader(filePath));
    String line;
    &lt;SPAN class="hljs-keyword"&gt;while&lt;/SPAN&gt; ((line = reader.readLine()) != &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;) {
        &lt;SPAN class="hljs-comment"&gt;// Process each line (e.g., print it)&lt;/SPAN&gt;
        System.out.println(line);
    }
    reader.close();
} &lt;SPAN class="hljs-keyword"&gt;catch&lt;/SPAN&gt; (Exception e) {
    e.printStackTrace();
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 23 Apr 2024 17:34:44 GMT</pubDate>
    <dc:creator>bob_lemley</dc:creator>
    <dc:date>2024-04-23T17:34:44Z</dc:date>
    <item>
      <title>How to use tJava to read the contents of a file</title>
      <link>https://community.qlik.com/t5/Data-Movement-Streaming/How-to-use-tJava-to-read-the-contents-of-a-file/m-p/2442748#M2141</link>
      <description>&lt;P&gt;I am trying to read the contents of a text file using a tJava component.&amp;nbsp; I have been having issues getting &lt;SPAN&gt;java.io.FileInputStream to work.&amp;nbsp; Does anyone have sample code on how to read a file?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 22:11:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Data-Movement-Streaming/How-to-use-tJava-to-read-the-contents-of-a-file/m-p/2442748#M2141</guid>
      <dc:creator>bob_lemley</dc:creator>
      <dc:date>2025-03-19T22:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to use tJava to read the contents of a file</title>
      <link>https://community.qlik.com/t5/Data-Movement-Streaming/How-to-use-tJava-to-read-the-contents-of-a-file/m-p/2444060#M2156</link>
      <description>&lt;P&gt;I ended up asking an AI for the answer and it gave it to me.&amp;nbsp; So some sample java code to read a file would look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="language-java"&gt;&lt;SPAN class="hljs-comment"&gt;// Specify the path to your file&lt;/SPAN&gt;
&lt;SPAN class="hljs-type"&gt;String&lt;/SPAN&gt; &lt;SPAN class="hljs-variable"&gt;filePath&lt;/SPAN&gt; &lt;SPAN class="hljs-operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="hljs-string"&gt;"C:\\path\\to\\your\\file.txt"&lt;/SPAN&gt;;

&lt;SPAN class="hljs-keyword"&gt;try&lt;/SPAN&gt; {
    java.io.&lt;SPAN class="hljs-type"&gt;BufferedReader&lt;/SPAN&gt; &lt;SPAN class="hljs-variable"&gt;reader&lt;/SPAN&gt; &lt;SPAN class="hljs-operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; &lt;SPAN class="hljs-title class_"&gt;java&lt;/SPAN&gt;.io.BufferedReader(&lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; &lt;SPAN class="hljs-title class_"&gt;java&lt;/SPAN&gt;.io.FileReader(filePath));
    String line;
    &lt;SPAN class="hljs-keyword"&gt;while&lt;/SPAN&gt; ((line = reader.readLine()) != &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;) {
        &lt;SPAN class="hljs-comment"&gt;// Process each line (e.g., print it)&lt;/SPAN&gt;
        System.out.println(line);
    }
    reader.close();
} &lt;SPAN class="hljs-keyword"&gt;catch&lt;/SPAN&gt; (Exception e) {
    e.printStackTrace();
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Apr 2024 17:34:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Data-Movement-Streaming/How-to-use-tJava-to-read-the-contents-of-a-file/m-p/2444060#M2156</guid>
      <dc:creator>bob_lemley</dc:creator>
      <dc:date>2024-04-23T17:34:44Z</dc:date>
    </item>
  </channel>
</rss>

