tags:

views:

69

answers:

2

I've found this method summary from Apace Commons APIDOC but I don't understand how to use it.

byte[]  decode(String pArray)
          Decodes a String containing containing characters in the Base64 alphabet.

Can you give the example of the syntax. I couldn't find the syntax in APIDOCs.

PS : this is from base64 decoding part. I understand the concept but want to use this method. I am looking for example code.

+1  A: 

Base64 is a scheme for representing bytes as String. If a String is a Base64 string, you pass it as argument to this method, and it returns the original bytes.

Here is your method

Bozho
Link to the example at http://en.wikipedia.org/wiki/Base64#Example
Stephen C
can you show in the code please
rover12
you have shown the code. You call the method (staticly) passing a String, and you get a byte array
Bozho
where is the method. which class contains the method. which libraries will be required to have that class.
rover12
Gave you a link in my answer.
Bozho
String srr = FileUtils.readFileToString(new File("c:\\test.txt"));byte b[] = new byte[16];how do i decode Contents of encoded string srr into byte b[]
rover12
+1  A: 

Code example as requested:

import org.apache.commons.codec.binary.Base64;

void example() {    
    String srr = FileUtils.readFileToString(new File("c:\\test.txt"));
    byte b[]; 
    Base64 base64 = new Base64();
    b=base64.decode(srr);
}
ammoQ
thanks a lot dear
rover12