cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
96
Views
0
Helpful
0
Comments
cdnadmin
Community Member
This document was generated from CDN thread

Created by: Bill Westby on 08-09-2010 09:05:13 PM
I'm trying to write to a text file inside a decision element and can't get the output to flush into the file.  I can create the files no problem but using standard BufferWriter technique to write the data produces no errors yet no data in the files, what am I missing here?
 
Code snip:

 ded.addToLog("INFO", "Checking if import file exists." + ciscoImportFile.getName());
if(!ciscoImportFile.exists())
{
  String entryString = "" + rtrCallKey.toString() + "|" + rtrCallDay.toString() + ","
              + dbqueue.toString() + "|" + dateTimePartPlusEWT.toString() + ","
              + custcbnum.toString() + ","
              + CTIRP.toString();
    ded.addToLog("INFO", "Try to write data to import file: " + entryString.toString());
  try
    {
        ciscoImportFile.getParentFile().mkdirs();
        ciscoImportFile.createNewFile();
       
        BufferedWriter outputWriter = new BufferedWriter(new FileWriter(ciscoImportFile.getName()));
        ded.addToLog("DEBUG", "Output writer: " + outputWriter.toString());
      outputWriter.write(entryString);
      outputWriter.newLine();
        outputWriter.close();
        ded.addToLog("INFO", "Cisco import file written successfully.");
    }
    catch(Throwable thrw)
    {
        ded.addToLog("ERROR", (new StringBuilder("Error occurred creating file: ")).append(ciscoImportFile.getCanonicalPath()).toString());
        throw thrw;
    }
 
The activity log shows success and the data I'm writing:
10.0.18.170.1283979327615.22.DB_CallBack_AgentFirst,09/08/2010 13:55:27.786,CreateAgentFirstCallback_01,custom,INFO,Cisco import file path: \\10.0.18.164\d$\DialerImport\callback.txt
10.0.18.170.1283979327615.22.DB_CallBack_AgentFirst,09/08/2010 13:55:27.786,CreateAgentFirstCallback_01,custom,INFO,Checking if import file exists.callback.txt
10.0.18.170.1283979327615.22.DB_CallBack_AgentFirst,09/08/2010 13:55:27.786,CreateAgentFirstCallback_01,custom,INFO,Try to write data to import file: 151515|161616HelpLine|2010-09-08 13:55:27|60031096245591039821133
10.0.18.170.1283979327615.22.DB_CallBack_AgentFirst,09/08/2010 13:55:27.786,CreateAgentFirstCallback_01,custom,DEBUG,Output writer: java.io.BufferedWriter@1604bee
10.0.18.170.1283979327615.22.DB_CallBack_AgentFirst,09/08/2010 13:55:27.786,CreateAgentFirstCallback_01,custom,INFO,Cisco import file written successfully.
10.0.18.170.1283979327615.22.DB_CallBack_AgentFirst,09/08/2010 13:55:27.802,CreateAgentFirstCallback_01,exit,Success
10.0.18.170.1283979327615.22.DB_CallBack_AgentFirst,09/08/2010 13:55:27.802,CVP Subdialog Return_01,enter,
10.0.18.170.1283979327615.22.DB_CallBack_AgentFirst,09/08/2010 13:55:27.818,CVP Subdialog Return_01,exit,
10.0.18.170.1283979327615.22.DB_CallBack_AgentFirst,09/08/2010 13:55:27.818,,end,how,app_session_complete
10.0.18.170.1283979327615.22.DB_CallBack_AgentFirst,09/08/2010 13:55:27.818,,end,result,normal
10.0.18.170.1283979327615.22.DB_CallBack_AgentFirst,09/08/2010 13:55:27.818,,end,duration,0
 
 
Any help is always appreciated.
 
Bill Westby
Medtronic Diabetes

Subject: RE: Writing to text file using java in decision element
Replied by: Bill Westby on 08-09-2010 09:55:54 PM
Figured it out finally, had to use dataoutputstream methods for whatever reason...

Final code block is:
 
 
 
 
 



 




String entryString = "" + rtrCallKey.toString() + "|" + rtrCallDay.toString() + ","
          + dbqueue.toString() + "|" + dateTimePartPlusEWT.toString() + ","
          + custcbnum.toString() + ","
          + CTIRP.toString();
ded.addToLog("INFO", "Try to write data to import file: " + entryString.toString());
try
{
    FileOutputStream fos = new FileOutputStream(ciscoImportFile);
    DataOutputStream outputWriter = new DataOutputStream(fos);
  outputWriter.writeBytes(entryString);
    outputWriter.close();
    ded.addToLog("INFO", "Cisco import file written successfully.");
}
catch(Throwable thrw)
{
    ded.addToLog("ERROR", (new StringBuilder("Error occurred creating file: ")).append(ciscoImportFile.getCanonicalPath()).toString());
    throw thrw;
}

Bill Westby
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links