Sample code for 30+ languages & platforms
Java

UU Encoding and Decoding

See more Encryption Examples

Demonstrates how to UU encode and decode.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.Crypt2;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example assumes the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Crypt2 crypt = new Crypt2();

        String s1 = "This string is to be UU encoded";

        crypt.setUuMode("666");
        crypt.setUuFilename("something.txt");

        // UU encode:
        String s2 = crypt.encodeString(s1, "ansi", "uu");

        // Note: Call crypt.Encode instead of crypt.EncodeString
        // to UU encode binary bytes (i.e. non-text binary data).

        System.out.println(s2);

        // UU decode:
        Crypt2 crypt2 = new Crypt2();
        String s3 = crypt2.decodeString(s2, "ansi", "uu");

        // Note: Likewise, call crypt.Decode to decode non-text binary data.

        System.out.println(s3);

        // Show the file permissions mode and filename found
        // in the UU encoded data:
        System.out.println("UuMode = " + crypt2.getUuMode());
        System.out.println("UuFilename = " + crypt2.getUuFilename());
    }
}