public void write(String content,boolean preserveSpaces) throws IOException {
  checkClosed();
  checkInit();
  if (!firstColumn) {
    outputStream.write(userSettings.Delimiter);
  }
  boolean textQualify=userSettings.ForceQualifier;
  if (content == null) {
    content=userSettings.NullString;
    textQualify=false;
    outputStream.write(content);
    firstColumn=false;
    return;
  }
 else   if (content.equals("")) {
    textQualify=true;
  }
  if (!preserveSpaces && content.length() > 0) {
    content=content.trim();
  }
  if (!textQualify && userSettings.UseTextQualifier && (content.indexOf(userSettings.TextQualifier) > -1 || content.indexOf(userSettings.Delimiter) > -1 || (!useCustomRecordDelimiter && (content.indexOf(Letters.LF) > -1 || content.indexOf(Letters.CR) > -1)) || (useCustomRecordDelimiter && content.indexOf(userSettings.RecordDelimiter) > -1) || (firstColumn && content.length() > 0 && content.charAt(0) == userSettings.Comment))) {
    textQualify=true;
  }
  if (userSettings.UseTextQualifier && !textQualify && content.length() > 0 && preserveSpaces) {
    char firstLetter=content.charAt(0);
    if (firstLetter == Letters.SPACE || firstLetter == Letters.TAB) {
      textQualify=true;
    }
    if (!textQualify && content.length() > 1) {
      char lastLetter=content.charAt(content.length() - 1);
      if (lastLetter == Letters.SPACE || lastLetter == Letters.TAB) {
        textQualify=true;
      }
    }
  }
  if (textQualify) {
    outputStream.write(userSettings.TextQualifier);
    if (userSettings.EscapeMode == ESCAPE_MODE_BACKSLASH) {
      content=replace(content,"" + Letters.BACKSLASH,"" + Letters.BACKSLASH + Letters.BACKSLASH);
      content=replace(content,"" + userSettings.TextQualifier,"" + Letters.BACKSLASH + userSettings.TextQualifier);
    }
 else {
      content=replace(content,"" + userSettings.TextQualifier,"" + userSettings.TextQualifier + userSettings.TextQualifier);
    }
  }
 else   if (userSettings.EscapeMode == ESCAPE_MODE_BACKSLASH) {
    content=replace(content,"" + Letters.BACKSLASH,"" + Letters.BACKSLASH + Letters.BACKSLASH);
    content=replace(content,"" + userSettings.Delimiter,"" + Letters.BACKSLASH + userSettings.Delimiter);
    if (useCustomRecordDelimiter) {
      content=replace(content,"" + userSettings.RecordDelimiter,"" + Letters.BACKSLASH + userSettings.RecordDelimiter);
    }
 else {
      content=replace(content,"" + Letters.CR,"" + Letters.BACKSLASH + Letters.CR);
      content=replace(content,"" + Letters.LF,"" + Letters.BACKSLASH + Letters.LF);
    }
    if (firstColumn && content.length() > 0 && content.charAt(0) == userSettings.Comment) {
      if (content.length() > 1) {
        content="" + Letters.BACKSLASH + userSettings.Comment+ content.substring(1);
      }
 else {
        content="" + Letters.BACKSLASH + userSettings.Comment;
      }
    }
  }
  outputStream.write(content);
  if (textQualify) {
    outputStream.write(userSettings.TextQualifier);
  }
  firstColumn=false;
}

public void write ( String content , boolean preserveSpaces ) throws IOException { checkClosed ( ) ; checkInit ( ) ; if ( ! firstColumn ) { outputStream . write ( userSettings . Delimiter ) ; } boolean textQualify = userSettings . ForceQualifier ; if ( content == null ) { content = userSettings . NullString ; textQualify = false ; outputStream . write ( content ) ; firstColumn = false ; return ; } else if ( content . equals ( "" ) ) { textQualify = true ; } if ( ! preserveSpaces && content . length ( ) > 0 ) { content = content . trim ( ) ; } if ( ! textQualify && userSettings . UseTextQualifier && ( content . indexOf ( userSettings . TextQualifier ) > - 1 || content . indexOf ( userSettings . Delimiter ) > - 1 || ( ! useCustomRecordDelimiter && ( content . indexOf ( Letters . LF ) > - 1 || content . indexOf ( Letters . CR ) > - 1 ) ) || ( useCustomRecordDelimiter && content . indexOf ( userSettings . RecordDelimiter ) > - 1 ) || ( firstColumn && content . length ( ) > 0 && content . charAt ( 0 ) == userSettings . Comment ) ) ) { textQualify = true ; } if ( userSettings . UseTextQualifier && ! textQualify && content . length ( ) > 0 && preserveSpaces ) { char firstLetter = content . charAt ( 0 ) ; if ( firstLetter == Letters . SPACE || firstLetter == Letters . TAB ) { textQualify = true ; } if ( ! textQualify && content . length ( ) > 1 ) { char lastLetter = content . charAt ( content . length ( ) - 1 ) ; if ( lastLetter == Letters . SPACE || lastLetter == Letters . TAB ) { textQualify = true ; } } } if ( textQualify ) { outputStream . write ( userSettings . TextQualifier ) ; if ( userSettings . EscapeMode == ESCAPE_MODE_BACKSLASH ) { content = replace ( content , "" + Letters . BACKSLASH , "" + Letters . BACKSLASH + Letters . BACKSLASH ) ; content = replace ( content , "" + userSettings . TextQualifier , "" + Letters . BACKSLASH + userSettings . TextQualifier ) ; } else { content = replace ( content , "" + userSettings . TextQualifier , "" + userSettings . TextQualifier + userSettings . TextQualifier ) ; } } else if ( userSettings . EscapeMode == ESCAPE_MODE_BACKSLASH ) { content = replace ( content , "" + Letters . BACKSLASH , "" + Letters . BACKSLASH + Letters . BACKSLASH ) ; content = replace ( content , "" + userSettings . Delimiter , "" + Letters . BACKSLASH + userSettings . Delimiter ) ; if ( useCustomRecordDelimiter ) { content = replace ( content , "" + userSettings . RecordDelimiter , "" + Letters . BACKSLASH + userSettings . RecordDelimiter ) ; } else { content = replace ( content , "" + Letters . CR , "" + Letters . BACKSLASH + Letters . CR ) ; content = replace ( content , "" + Letters . LF , "" + Letters . BACKSLASH + Letters . LF ) ; } if ( firstColumn && content . length ( ) > 0 && content . charAt ( 0 ) == userSettings . Comment ) { if ( content . length ( ) > 1 ) { content = "" + Letters . BACKSLASH + userSettings . Comment + content . substring ( 1 ) ; } else { content = "" + Letters . BACKSLASH + userSettings . Comment ; } } } outputStream . write ( content ) ; if ( textQualify ) { outputStream . write ( userSettings . TextQualifier ) ; } firstColumn = false ; }
writes another column of data to this record .
