本人是在获取邮件附件Content时遇到的错误 也适用于其他情况获取信息
如果是为了获取信息
下面为解决代码
StringBuffer content=new StringBuffer
try{
o = part.getContent();
}catch(UnsupportedEncodingException e){
InputStream is = part.getInputStream();
content.append(inputStream2String(is));
continue;
}
public static String inputStream2String(InputStream in)throws IOException {
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
for(int n; (n=in.read(b))!=-1;){
out.append(new String(b,0,n));
}
return out.toString();
}
可将附件内容转换为String