Hi All,
I have some doubts regarding accessing file from PI application server. I am writing UDF which reads say "plant.txt" flat file from the PI application server. Is it possible to access file in UDF?
Below is the sample code I have wriiten in eclipse editor which is working fine. And tell where I need to keep this file.
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public
class CsvTest {
public void readFile() {
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("D://plant.txt"));
String line = null;
int totalElements=0;
while ((line = br.readLine()) != null) {
String[] values = line.split(",");
totalElements= totalElements + values.length;
for(int i=0;i<values.length;i++)
{ System.out.println(values<i>);
}
}
System.out.println(totalElements);
}
catch (FileNotFoundException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
finally {
try {
if (br != null)
br.close();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
public static void main(String[] args) {
CsvTest test =
new CsvTest();
test.readFile();
}
}
Please help me out.
Thanks in Advance,
Nisha