Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to use Mime encoding and decoding in Java

1 Answer

0 votes
import java.io.UnsupportedEncodingException;
import java.util.Base64;
import java.util.Base64.Encoder;

public class MyClass {
    public static void main(String args[]) throws UnsupportedEncodingException {
        String s =  "Java programming language";
        byte[] bytes_array = s.getBytes("UTF-8");
        
        Encoder encoder = Base64 .getMimeEncoder();
        String encode_string = encoder.encodeToString(bytes_array);
        System.out.println(encode_string);
        
        String decode_string = new String(Base64.getMimeDecoder().decode(encode_string));
        System.out.println(decode_string);
    }
}




/*
run:

SmF2YSBwcm9ncmFtbWluZyBsYW5ndWFnZQ==
Java programming language

*/

 



answered Jan 3, 2022 by avibootz

Related questions

2 answers 150 views
150 views asked Jan 3, 2022 by avibootz
1 answer 189 views
1 answer 131 views
2 answers 198 views
1 answer 113 views
113 views asked Apr 2, 2021 by avibootz
1 answer 179 views
...