简体   繁体   中英

How to clone a NotesDocument java object

I have the following java code and when I try to access the MiscDoc object later it seem to be null. I could not find a.clone() method on NotesDocument.

the if statement is only accessed once

Document MiscDoc = null;
wdoc = dcAll.getFirstDocument();
while (wdoc != null){       
            if(...){
                MiscDoc = wdoc;
            }
            Document tmpdoc = dcAll.getNextDocument();
            wdoc.recycle();
            wdoc = tmpdoc;
}

how can I resolve this

As you recycle every document in while loop your MiscDoc is also recycled and null after loop.

Just don't recycle this certain document and it will be available after while loop.

Easiest way is to add break; if you are just looking for the first document that matches if(...) condition:

while (wdoc != null) {       
    if(...){
        MiscDoc = wdoc;
        break;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM