0

如何在 scriptella 中编写以下代码?看起来它认为我正在尝试比较 Set 和 String,并且它不喜欢最后一个 for 循环。以及写 && 之类的逻辑表达式的方法是什么。谢谢你。

<connection id="java" driver="scriptella.driver.janino.Driver"/>

<script connection-id="java>

//some code

if(finalOrderCounter &lt; numberOfEntries){
    Set &lt;String> set = new HashSet &lt;String>();
    for(int i = 0; i &lt; fieldNames.length; i++){
        set.add(fieldNames[i]);
    }
    for(int i = 0; i &lt; fieldNamesFromXML.length; i++){
        set.remove(fieldNamesFromXML[i]);
    }
    String exception = "";
    for(String element:set)
        exception += element +"\n";
    throw new IOException("Field(s)\n" + exception + "do(es) not exits in the source database");
}

4

1 回答 1

0

也许您可以尝试“经典”“for”循环语法?

StringBuffer exception = new StringBuffer();
for (int i = 0; i &lt; set.size(); ++i) {
    String element = (String) set.get(i);
    exception.append(element);
    exception.append("\n");
}
throw new IOException("Field(s)\n" + exception.toString() + "do(es) not exits in the source database");

顺便说一句,你得到什么错误?

于 2013-03-17T07:21:03.323 回答