UTF-8 to Mail Header converter

This page can convert any UTF-8 string to ASCII characters that can be used in mail headers (e.g. Subject line).
For example, the UTF-8 string "2πr" will be displayed as =?UTF-8?Q?2=CF=80r?=.

Here's some additional helpful UTF-8 characters to copy and paste:
Greek: Όταν μπώ σε λειτουργία δεν είναι πολύ δύσκολο να συνεχίσω.
Czech and Slovak: š ť ž ľ č ě ď ň ř ů ĺ Š Ť Ž Ľ Č Ě Ď Ň Ř Ů Ĺ
Emoji: 😀 🍇🍈🍉🍊🍋🍌🍍🥭🍎🍏🍐🍑🍒🍓🥝🍅🥥

UTF-8 input

Type in some UTF-8 text and press the [Submit] button:

How can I do this myself using Java?

Here's the Java source code for UTF-8 to java code conversion. Source code courtesy Francis Devereux.