Java 如何提取Lotus Notes数据库图标?

Java 如何提取Lotus Notes数据库图标?,java,lotus-notes,Java,Lotus Notes,我曾尝试使用DXL Exporter提取LotusNotes数据库图标,但没有成功。结果文件已损坏,无法由图像查看器打开 如何使用java提取Lotus Notes数据库图标 private String extractDatabaseIcon() { String tag = ""; String idfile = ""; String password = ""; String dbfile = ""; NotesThread.sinitThread(

我曾尝试使用DXL Exporter提取LotusNotes数据库图标,但没有成功。结果文件已损坏,无法由图像查看器打开

如何使用java提取Lotus Notes数据库图标

private String extractDatabaseIcon() {
    String tag = "";
    String idfile = "";
    String password = "";
    String dbfile = "";
    NotesThread.sinitThread();
    Session s = NotesFactory.createSessionWithFullAccess();
    s.createRegistration().switchToID(idfile, password);
    Database d = s.getDatabase("", dbfile);

    NoteCollection nc = d.createNoteCollection(false);
    nc.setSelectIcon(true);
    nc.buildCollection();
    String noteId = nc.getFirstNoteID();
    int counter = 0;
    while (noteId != null) {
        counter++;
        try {
            Document doc = d.getDocumentByID(noteId);
            DxlExporter dxl = s.createDxlExporter();
            String xml = dxl.exportDxl(doc);
            xml = xml.substring(xml.indexOf("<note "));
            org.jsoup.nodes.Document jdoc = Jsoup.parse(xml);
            Element ele = jdoc.select("rawitemdata").first();
            String raw = ele.text().trim();
            String temp = System.getProperty("java.io.tmpdir") + UUID.randomUUID().toString() + "\\";
            File file = new File(temp);
            file.mkdir();
            String filename = temp + UUID.randomUUID().toString().replaceAll("-", "") + ".gif";
            byte[] buffer = decode(raw.getBytes());
            FileOutputStream fos = new FileOutputStream(filename);
            fos.write(buffer);
            fos.close();
            tag = filename;
        } catch (Exception e) {
            logger.error("", e);
        }

        if (counter >= nc.getCount()) {
            noteId = null;
        } else {
            noteId = nc.getNextNoteID(noteId);
        }
   }
   return tag;
}

private byte[] decode(byte[] b) throws Exception {
    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    InputStream b64is = MimeUtility.decode(bais, "base64");
    byte[] tmp = new byte[b.length];
    int n = b64is.read(tmp);
    byte[] res = new byte[n];
    System.arraycopy(tmp, 0, res, 0, n);
    return res;
}  
private String extractDatabaseIcon(){
字符串标签=”;
字符串idfile=“”;
字符串密码=”;
字符串dbfile=“”;
NotesThread.sinitThread();
会话s=NotesFactory.createSessionWithFullAccess();
s、 createRegistration().switchToID(idfile,密码);
数据库d=s.getDatabase(“,dbfile);
NoteCollection nc=d.createNoteCollection(false);
nc.设置选择图标(真);
nc.buildCollection();
字符串noteId=nc.getFirstNoteID();
int计数器=0;
while(noteId!=null){
计数器++;
试一试{
Document doc=d.getDocumentByID(noteId);
DxlExporter dxl=s.createDxlExporter();
字符串xml=dxl.exportDxl(doc);

xml=xml.substring(xml.indexOf(“我不确定格式是什么。据我所知”这是一个16色位图,但不是标准的BMP文件格式。而且它肯定不是GIF格式,但您可以告诉DXLExporter将其转换。默认情况下是将其保留为本机格式,因此您需要在导出之前将其添加到代码中:

dxl.setConvertNotesBitmapsToGIF(true);

我不确定格式是什么。据我所知,这是一个16色位图,但不是标准的BMP文件格式。而且它肯定不是GIF格式,但您可以告诉DXLExporter将其转换。默认情况下是将其保留为本机格式,因此您需要在导出之前将其添加到代码中:

dxl.setConvertNotesBitmapsToGIF(true);

它甚至不是位图,而是一个图标。您可以在此处找到其格式:

很久以前,我在LotusScript中成功地做到了这一点。我的代码基于此页面的早期版本:

对于图标本身,您只需打开一个文档:

NotesDocument doc = db.getDocumentByID("FFFF8010")
exporter = session.createDXLExporter
exporter.setConvertNotesBitmapsToGIF(false)
outputXML = exporter.export(doc)

然后解析XML以从IconBitmap项中查找rawitemdata,就像您在原始代码中所做的那样。

它甚至不是位图,而是图标。您可以在此处找到格式:

很久以前,我在LotusScript中成功地做到了这一点。我的代码基于此页面的早期版本:

对于图标本身,您只需打开一个文档:

NotesDocument doc = db.getDocumentByID("FFFF8010")
exporter = session.createDXLExporter
exporter.setConvertNotesBitmapsToGIF(false)
outputXML = exporter.export(doc)

然后解析XML以从IconBitmap项中查找rawitemdata,就像您在原始代码中所做的那样。

我尝试了dxl.setConvertNotesBitMacLogif(true)但未成功。结果文件仍然损坏。我尝试了dxl.setConvertNotesBitMacLogif(true)但未成功。结果文件仍然损坏。请使用stream.Open(“dbicon.ico”)“,”二进制“)和流。写(…)如何从项中获取流?我只找到项。getInputStream(),但流总是空的。对不起,你是对的,这是一个厚厚的灰尘层下的非常旧的代码…我修改了上面的信息。最后512字节包含位图数据。图像是16色32x32位图。请参阅使用stream.Open(“dbicon.ico”,“Binary”)和stream.write(…)如何从项中获取流?我只找到了项。getInputStream(),但流总是空的。对不起,你说得对,这是一个很旧的代码,有一层厚厚的灰尘…我修改了上面的信息。最后512字节包含位图数据。图像是16色32x32位图。请参阅