the different ways of base64

类别:Java 点击:0 评论:0 推荐:

import java.io.*;
import sun.misc.*;

public class DeEnBase64{
 public static void main(String args[]) throws Exception{

  File f=new File("C:/aa.bmp");
  FileInputStream fis=new FileInputStream(f);
  FileOutputStream fos=new FileOutputStream("c:/bb.bmp");
  
  byte[] by=new byte[(int)f.length()];
  fis.read(by);
  
  //from soap.jar;
  //String s=new org.apache.soap.encoding.soapenc.Base64().encode(by);
  //from axis.jar;
  String s=new org.apache.axis.encoding.Base64().encode(by);
  
  //from standard jdk;
  //String s=new sun.misc.BASE64Encoder().encode(by);

  fos.write(new BASE64Decoder().decodeBuffer(s));
  System.out.println(s.length());  
  
 }
}

本文地址:http://com.8s8s.com/it/it16104.htm