我使用Windows桌面搜索开发Java应用程序,从中可以检索有关计算机文件的一些信息,例如url(System.ItemUrl)。这样的URL的一个例子是
file://c:/users/ausername/documents/aninterestingfile.txt
用于“普通”文件。此字段还提供从Outlook或Thunderbird索引的邮件项目的URL。雷鸟的项目(仅适用于Vista和7)也是文件(.wdseml)。但是Outlook的项目网址以“
mapi://”开头,例如:
mapi://{S-1-5-21-1626573300-1364474481-487586288-1001}/toto@mycompany.com($b423dcd5)/0/Inbox/가가가가곕갘객겒갨겑곓걌게겻겨곹곒갓곅갩갤가갠가
我遇到的问题是使用此URL在Outlook中从Java打开实际项目。如果我在Windows的“运行”对话框中复制/粘贴它,则它可以工作;如果我在命令行中使用“开始”后跟复制/粘贴的网址,它也可以使用。
该网址似乎采用UTF-16编码。我希望能够编写这样的代码:
String url = "mapi://{S-1-5-21-1626573300-1364474481-487586288-1001}/toto@mycompany.com($b423dcd5)/0/Inbox/가가가가곕갘객겒갨겑곓걌게겻겨곹곒갓곅갩갤가갠가";
Runtime.getRuntime().exec("cmd.exe /C start " + url);
我不工作,并且尝试了其他解决方案,例如:
String start = "start";
String url = "mapi://{S-1-5-21-1626573300-1364474481-487586288-1001}/toto@mycompany.com($b423dcd5)/0/Inbox/가가가가곕갘객겒갨겑곓걌게겻겨곹곒갓곅갩갤가갠가";
FileOutputStream fos = new FileOutputStream(new File("test.bat");
fos.write(start.getBytes("UTF16");
fos.write(url.getBytes("UTF16"));
fos.close();
Runtime.getRuntime().exec("cmd.exe /C test.bat");
没有任何成功。使用上述解决方案,文件“ test.bat”包含正确的url和“ start”命令,但是运行“ test.bat”会导致众所周知的错误消息:
'■' is not recognized as an internal or external command, operable program or batch file.
有没有人能从Java中打开“ mapi://”项?