Hey Ak,
Theo gave you good information. However, to write the file, you will need to create a simple writeFile java service.
Here is one for you to help with this task:
INPUT:
T - fileContents
T - fileName (this includes full path /usr/home/yourfile.txt)
OUTPUT:
T - serviceMessage
Possible serviceMessages:
WF-01 - File Written
WF-02 - Error
Imports:
java.io.*
java.lang.*
java.util.*
java.text.*
(you can probably get rid of some of these imports, but I need
them because they are shared)
Here’s the code:
// fileContents - String contents of file.
// fileName - name of file you want to write.
IDataHashCursor idhc = pipeline.getHashCursor();
idhc.first( “fileContents” );
String fileContents = (String) idhc.getValue();
idhc.first( “fileName” );
String fileName = (String) idhc.getValue();
idhc.destroy();
String serviceMessage = “”;
try {
char buffer = new char[fileContents.length()];
fileContents.getChars(0, fileContents.length(), buffer, 0);
FileWriter fw = new FileWriter(fileName,true);
fw.write(buffer);
fw.close();
serviceMessage = “WF-01”;
} catch (Exception e) {
serviceMessage = “WF-02”;
}
// output pipeline
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
IDataUtil.put( pipelineCursor, “serviceMessage”, serviceMessage );
pipelineCursor.destroy();
There may be a better way to write this code, but this has worked
for me for over two years without any problems.