门:常规循环中的每个循环后的断裂线

时间:2018-07-26 23:31:02

标签: groovy gate

我有此代码,每个循环后在同一行中打印。例如:

“类别=超文字”,“ remarque = confusion_consonne”,“ mot =文章”,“ categorie = logogrammique”,“ remarque =撇号”,“ mot = conjonction”

每个循环后我都希望换行,但/ n不起作用,writeLine会做另一件事。

所需的输出为: “类别=超文字”,“ remarque = confusion_consonne”,“ mot =文章” “ categorie = logogrammique”,“ remarque =撇号”,“ mot = conjonction”

  new File("/outfile.txt").withWriterAppend{ out ->
  (doc.getNamedAnnotationSets() + [Default:(doc.getAnnotations())]).each{ setName, set ->
    set.each{ anno ->
      if( anno.getFeatures() )
        anno.getFeatures().each{ fValue ->
          out.write(/"${fValue}",/)
        }
      else
        out.write(/"${anno.getId()},,/)        
    }
  }
}

提前考虑

1 个答案:

答案 0 :(得分:0)

那又怎么样:

  new File("/outfile.txt").withWriterAppend{ out ->
  (doc.getNamedAnnotationSets() + [Default:(doc.getAnnotations())]).each{ setName, set ->
    set.each{ anno ->
      if( anno.getFeatures() )
        anno.getFeatures().each{ fValue ->
          out.write(/"${fValue}",/)
        }
      else
        out.write(/"${anno.getId()},,/)        

      out.write('\n') //this line is new
    }
  }
}