Mercurial Hosting > luan
comparison src/goodjava/util/GoodUtils.java @ 1583:1cc6c7fa803d
mail work
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 07 Mar 2021 02:22:09 -0700 |
| parents | |
| children | 2f4c99c02436 |
comparison
equal
deleted
inserted
replaced
| 1582:f28cc30d56cb | 1583:1cc6c7fa803d |
|---|---|
| 1 package goodjava.util; | |
| 2 | |
| 3 import java.io.UnsupportedEncodingException; | |
| 4 import java.util.Base64; | |
| 5 | |
| 6 | |
| 7 public final class GoodUtils { | |
| 8 | |
| 9 public static byte[] getBytes(String s,String charsetName) { | |
| 10 try { | |
| 11 return s.getBytes(charsetName); | |
| 12 } catch(UnsupportedEncodingException e) { | |
| 13 throw new RuntimeException(e); | |
| 14 } | |
| 15 } | |
| 16 | |
| 17 public static String base64Encode(String s) { | |
| 18 return Base64.getEncoder().encodeToString(getBytes(s,"UTF-8")); | |
| 19 } | |
| 20 } |
