我正在尝试从Messages文件夹中获取附件内容。但它显示空字符串,虽然它正确返回名称和大小。对于每个文件(txt,html或其他),它不返回任何字符串值。为此我写下面的代码:
public boolean supports(String contentType)
{
boolean val;
if (contentType.toLowerCase().indexOf("txt") != -1)
{
val = true;
}
else
val = false;
return val;
}
public void run(Message m, SupportedAttachmentPart p)
{
MainScreen view = new MainScreen();
view.setTitle("Attachment Viewer");
view.add(new RichTextField(new String((byte[])p.getContent())));
view.add(new RichTextField(new String(p.getFilename())));
// PasswordScreen pwd = new PasswordScreen();
Logger.out("eMailMinderApp", "Attachment Content" +new RichTextField(new String((byte[])p.getContent())));
Ui.getUiEngine().pushGlobalScreen(view, 1, UiEngine.GLOBAL_QUEUE);
}
任何人都可以帮助我......因为我在最后两天被困在这里..