Does Java has any standard mechanism for uudecodin

2020-02-14 10:53发布

问题:

I was writing a Java program to download attachments from POP3 email. Originally I do this with getting an input stream of a MimePart if its content type is validated. And then I can simply write the input stream into a local file through a FileOutputStream.

However, one thing I encountered is that, after I received an email with an attached file as its only content and access it, the mail (of type Message) only consists of a single part, which is of type text/plain. And its content consists of massive random-looking character.

After searching through the internet I found that the file is uuencoded. Then I tried to find if there is any standard library for decoding it but seems I ran out of luck. So I would like to know is there any standard/ usual ways to decode it and obtain the attached file? Thanks a lot.

回答1:

Yes, the "Java(TM) EE 7 Specification APIs" supports encoding and decoding with uuencode.

See MimeUtility.decode():

In addition, "uuencode" is also supported.