Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    Java Base64 1.3.1

    Download button

    No screenshots available
    Downloads: 1,865  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Carlo Pelliccia | More programs
    LGPL / FREE
    April 14th, 2009, 12:56 GMT [view history]
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Java Base64 description

    A Base64 encoder and decoder

    Using Java Base64 will enable Java applications to encode and decode base64 streams and strings.

    Installation

    Add the javabase64-1.3.jar file to your application classpath, and you'll be automatically enabled to the use of the javabase64 classes.

    Quickstart

    The javabase64 library consists of two streams and a utility class.

    The it.sauronsoftware.base64.Base64 utility class is, in most of cases, has everything you need to encode and decode.

    First of all, you should tell apart if you have to encode/decode a string or a binary stream.

    If you want to encode a string, you can easily call:

    String encoded = Base64.encode("Hello, world!");

    The result of this operation is a Base64 encoded string, that you can decode back later by calling:

    String decoded = Base64.decode(encoded);

    You can force the use of a specific charset during strings encoding and decoding operations:

    String encoded = Base64.encode("Hello, world!", "UTF-8");
    String decoded = Base64.decode(encoded, "UTF-8");

    If you are working with binary data (i.e. images) you can use other forms of the encode() and decode() methods.

    If data are not large and you handle them directly in memory, using a byte array:

    byte[] source = ...; // load your data here
    byte[] encoded = Base64.encode(source);
    byte[] decoded = Base64.decode(encoded);


    Larger data are better handled with streams. The next sample code encodes a file to another, using java.io.InputStream and java.io.OutputStream objects:

    InputStream inputStream = new FileInputStream("source.jpg");
    OutputStream outputStream = new FileOutputStream("encoded.b64");
    Base64.encode(inputStream, outputStream);
    outputStream.close();
    inputStream.close();


    In similar manner, a stream can be decoded:

    InputStream inputStream = new FileInputStream("encoded.b64");
    OutputStream outputStream = new FileOutputStream("decoded.jpg");
    Base64.decode(inputStream, outputStream);
    outputStream.close();
    inputStream.close();


    Shortcuts for java.io.File objects are provided. Encoding from a file to another:

    File source = new File("source.jpg");
    File encoded = new File("encoded.b64");
    Base64.encode(source, encoded);


    Decoding from a file to another:

    File encoded = new File("encoded.b64");
    File decoded = new File("decoded.jpg");
    Base64.decode(encoded, decoded);



    Product's homepage

    Requirements:

    · Java 2 Standard Edition Runtime Environment

    What's New in This Release: [ read full changelog ]

    · Bugfix in the Base64.encode(InputStream,OutputStream,int) method

      


    TAGS:

    Java Base64 | Strings decoder | Base64 | streams | strings

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM