Package net.sf.xbus.base.linereader

Examples of net.sf.xbus.base.linereader.LineReader


  public Object execute(String function, Object source) throws XException
  {
    senderExecuted = true;

    LineReader reader = null;
    BufferedWriter buffOut = null;
    try
    {
      reader = (LineReader) source;
      reader.prepareReading(mDestination);
      buffOut = prepareWriter(mConfiguration.getFileNames()[0], 0);

      String record = reader.readRecord();
      String lastRecord = "";

      if (record != null)
      {
        buffOut.write(record);
        lastRecord = record;
        record = reader.readRecord();
      } // while (record != null)
      while (record != null)
      {
        buffOut.write(Constants.LINE_SEPERATOR);
        buffOut.write(record);
        lastRecord = record;
        record = reader.readRecord();
      } // while (record != null)

      // Writing an end of file sign on Unix systems
      if (Constants.LINE_SEPERATOR.equals("\n")
          && (lastRecord.length() == 0 || lastRecord
              .charAt(lastRecord.length() - 1) != '\n'))
        buffOut.newLine();
    }
    catch (Exception e)
    {
      throw new XException(Constants.LOCATION_EXTERN,
          Constants.LAYER_TECHNICAL,
          Constants.PACKAGE_TECHNICAL_FILE, "0", e);
    }
    finally
    {
      try
      {
        if (reader != null)
        {
          reader.terminateReading();
        }
        if (buffOut != null)
        {
          buffOut.close();
        }
View Full Code Here

TOP

Related Classes of net.sf.xbus.base.linereader.LineReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.