📄 base64.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.6.0_04) on Sat May 17 11:57:54 CEST 2008 --><TITLE>Base64</TITLE><META NAME="date" CONTENT="2008-05-17"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Base64"; }}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><HR><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><a href="http://www.1t3xt.com/docs/book.php" target="_blank"><img src="http://www.1t3xt.com/img/book/lowagie_3d.jpg" border="0" /></a></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> PREV CLASS <A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.InputStream.html" title="class in com.lowagie.text.pdf.codec"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?com/lowagie/text/pdf/codec/Base64.html" target="_top"><B>FRAMES</B></A> <A HREF="Base64.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: <A HREF="#nested_class_summary">NESTED</A> | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">com.lowagie.text.pdf.codec</FONT><BR>Class Base64</H2><PRE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A> <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>com.lowagie.text.pdf.codec.Base64</B></PRE><HR><DL><DT><PRE>public class <B>Base64</B><DT>extends <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL></PRE><P><p>Encodes and decodes to and from Base64 notation.</p> <p>Homepage: <a href="http://iharder.net/base64">http://iharder.net/base64</a>.</p> <p> Change Log: </p> <ul> <li>v2.2.1 - Fixed bug using URL_SAFE and ORDERED encodings. Fixed bug when using very small files (~< 40 bytes).</li> <li>v2.2 - Added some helper methods for encoding/decoding directly from one file to the next. Also added a main() method to support command line encoding/decoding from one file to the next. Also added these Base64 dialects: <ol> <li>The default is RFC3548 format.</li> <li>Calling Base64.setFormat(Base64.BASE64_FORMAT.URLSAFE_FORMAT) generates URL and file name friendly format as described in Section 4 of RFC3548. http://www.faqs.org/rfcs/rfc3548.html</li> <li>Calling Base64.setFormat(Base64.BASE64_FORMAT.ORDERED_FORMAT) generates URL and file name friendly format that preserves lexical ordering as described in http://www.faqs.org/qa/rfcc-1940.html</li> </ol> Special thanks to Jim Kellerman at <a href="http://www.powerset.com/">http://www.powerset.com/</a> for contributing the new Base64 dialects. </li> <li>v2.1 - Cleaned up javadoc comments and unused variables and methods. Added some convenience methods for reading and writing to and from files.</li> <li>v2.0.2 - Now specifies UTF-8 encoding in places where the code fails on systems with other encodings (like EBCDIC).</li> <li>v2.0.1 - Fixed an error when decoding a single byte, that is, when the encoded data was a single byte.</li> <li>v2.0 - I got rid of methods that used booleans to set options. Now everything is more consolidated and cleaner. The code now detects when data that's being decoded is gzip-compressed and will decompress it automatically. Generally things are cleaner. You'll probably have to change some method calls that you were making to support the new options format (<tt>int</tt>s that you "OR" together).</li> <li>v1.5.1 - Fixed bug when decompressing and decoding to a byte[] using <tt>decode( String s, boolean gzipCompressed )</tt>. Added the ability to "suspend" encoding in the Output Stream so you can turn on and off the encoding if you need to embed base64 data in an otherwise "normal" stream (like an XML file).</li> <li>v1.5 - Output stream pases on flush() command but doesn't do anything itself. This helps when using GZIP streams. Added the ability to GZip-compress objects before encoding them.</li> <li>v1.4 - Added helper methods to read/write files.</li> <li>v1.3.6 - Fixed OutputStream.flush() so that 'position' is reset.</li> <li>v1.3.5 - Added flag to turn on and off line breaks. Fixed bug in input stream where last buffer being read, if not completely full, was not returned.</li> <li>v1.3.4 - Fixed when "improperly padded stream" error was thrown at the wrong time.</li> <li>v1.3.3 - Fixed I/O streams which were totally messed up.</li> </ul> <p> I am placing this code in the Public Domain. Do with it as you will. This software comes with no guarantees or warranties but with plenty of well-wishing instead! Please visit <a href="http://iharder.net/base64">http://iharder.net/base64</a> periodically to check for updates or to contribute improvements. </p><P><P><DL><DT><B>Version:</B></DT> <DD>2.2.1</DD><DT><B>Author:</B></DT> <DD>Robert Harder, rob@iharder.net</DD></DL><HR><P><!-- ======== NESTED CLASS SUMMARY ======== --><A NAME="nested_class_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Nested Class Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.InputStream.html" title="class in com.lowagie.text.pdf.codec">Base64.InputStream</A></B></CODE><BR> A <A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.InputStream.html" title="class in com.lowagie.text.pdf.codec"><CODE>Base64.InputStream</CODE></A> will read data from another <tt>java.io.InputStream</tt>, given in the constructor, and encode/decode to/from Base64 notation on the fly.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.OutputStream.html" title="class in com.lowagie.text.pdf.codec">Base64.OutputStream</A></B></CODE><BR> A <A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.OutputStream.html" title="class in com.lowagie.text.pdf.codec"><CODE>Base64.OutputStream</CODE></A> will write data to another <tt>java.io.OutputStream</tt>, given in the constructor, and encode/decode to/from Base64 notation on the fly.</TD></TR></TABLE> <!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Field Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>private static byte[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.html#_ORDERED_ALPHABET">_ORDERED_ALPHABET</A></B></CODE><BR> I don't get the point of this technique, but it is described here: <a href="http://www.faqs.org/qa/rfcc-1940.html">http://www.faqs.org/qa/rfcc-1940.html</a>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>private static byte[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.html#_ORDERED_DECODABET">_ORDERED_DECODABET</A></B></CODE><BR> Used in decoding the "ordered" dialect of Base64.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>private static byte[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.html#_STANDARD_ALPHABET">_STANDARD_ALPHABET</A></B></CODE><BR> The 64 valid Base64 values.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>private static byte[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.html#_STANDARD_DECODABET">_STANDARD_DECODABET</A></B></CODE><BR> Translates a Base64 value to either its 6-bit reconstruction value or a negative number indicating some other meaning.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>private static byte[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.html#_URL_SAFE_ALPHABET">_URL_SAFE_ALPHABET</A></B></CODE><BR> Used in the URL- and Filename-safe dialect described in Section 4 of RFC3548: <a href="http://www.faqs.org/rfcs/rfc3548.html">http://www.faqs.org/rfcs/rfc3548.html</a>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>private static byte[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.html#_URL_SAFE_DECODABET">_URL_SAFE_DECODABET</A></B></CODE><BR> Used in decoding URL- and Filename-safe dialects of Base64.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.html#DECODE">DECODE</A></B></CODE><BR> Specify decoding.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.html#DONT_BREAK_LINES">DONT_BREAK_LINES</A></B></CODE><BR> Don't break lines when encoding (violates strict Base64 specification)</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../com/lowagie/text/pdf/codec/Base64.html#ENCODE">ENCODE</A></B></CODE><BR> Specify encoding.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -