資源簡介
android Base64 類,源碼,copy過去 即可用
代碼片段和文件信息
/*
?*?Copyright?(C)?2010?The?Android?Open?Source?Project
?*
?*?Licensed?under?the?Apache?License?Version?2.0?(the?“License“);
?*?you?may?not?use?this?file?except?in?compliance?with?the?License.
?*?You?may?obtain?a?copy?of?the?License?at
?*
?*??????http://www.apache.org/licenses/LICENSE-2.0
?*
?*?Unless?required?by?applicable?law?or?agreed?to?in?writing?software
?*?distributed?under?the?License?is?distributed?on?an?“AS?IS“?BASIS
?*?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND?either?express?or?implied.
?*?See?the?License?for?the?specific?language?governing?permissions?and
?*?limitations?under?the?License.
?*/
package?android.util;
import?java.io.UnsupportedEncodingException;
/**
?*?Utilities?for?encoding?and?decoding?the?base64?representation?of
?*?binary?data.??See?RFCs??*?href=“http://www.ietf.org/rfc/rfc2045.txt“>2045?and??*?href=“http://www.ietf.org/rfc/rfc3548.txt“>3548.
?*/
public?class?base64?{
????/**
?????*?Default?values?for?encoder/decoder?flags.
?????*/
????public?static?final?int?DEFAULT?=?0;
????/**
?????*?Encoder?flag?bit?to?omit?the?padding?‘=‘?characters?at?the?end
?????*?of?the?output?(if?any).
?????*/
????public?static?final?int?NO_PADDING?=?1;
????/**
?????*?Encoder?flag?bit?to?omit?all?line?terminators?(i.e.?the?output
?????*?will?be?on?one?long?line).
?????*/
????public?static?final?int?NO_WRAP?=?2;
????/**
?????*?Encoder?flag?bit?to?indicate?lines?should?be?terminated?with?a
?????*?CRLF?pair?instead?of?just?an?LF.??Has?no?effect?if?{@code
?????*?NO_WRAP}?is?specified?as?well.
?????*/
????public?static?final?int?CRLF?=?4;
????/**
?????*?Encoder/decoder?flag?bit?to?indicate?using?the?“URL?and
?????*?filename?safe“?variant?of?base64?(see?RFC?3548?section?4)?where
?????*?{@code?-}?and?{@code?_}?are?used?in?place?of?{@code?+}?and
?????*?{@code?/}.
?????*/
????public?static?final?int?URL_SAFE?=?8;
????/**
?????*?Flag?to?pass?to?{@link?base64OutputStream}?to?indicate?that?it
?????*?should?not?close?the?output?stream?it?is?wrapping?when?it
?????*?itself?is?closed.
?????*/
????public?static?final?int?NO_CLOSE?=?16;
????//??--------------------------------------------------------
????//??shared?code
????//??--------------------------------------------------------
????/*?package?*/?static?abstract?class?Coder?{
????????public?byte[]?output;
????????public?int?op;
????????/**
?????????*?Encode/decode?another?block?of?input?data.??this.output?is
?????????*?provided?by?the?caller?and?must?be?big?enough?to?hold?all
?????????*?the?coded?data.??On?exit?this.opwill?be?set?to?the?length
?????????*?of?the?coded?data.
?????????*
?????????*?@param?finish?true?if?this?is?the?final?call?to?process?for
?????????*????????this?object.??Will?finalize?the?coder?state?and
?????????*????????include?any?final?bytes?in?the?output.
?????????*
?????????*?@return?true?if?the?input?so?far?is?good;?false?if?some
?????????*?????????error?has?been?detected?in?the?input?stream..
?????????*/
????????public?abstract?boolean?process(byt
評論
共有 條評論