<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FDevelopment_Class%2FAscii_Code</id>
		<title>Java/Development Class/Ascii Code - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FDevelopment_Class%2FAscii_Code"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Ascii_Code&amp;action=history"/>
		<updated>2026-04-19T04:27:06Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Development_Class/Ascii_Code&amp;diff=8459&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Ascii_Code&amp;diff=8459&amp;oldid=prev"/>
				<updated>2010-06-01T07:06:47Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 07:06, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Development_Class/Ascii_Code&amp;diff=8458&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Ascii_Code&amp;diff=8458&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:46Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Add a ASCII85 encoding to the stream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
/*&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one or more&lt;br /&gt;
 * contributor license agreements.  See the NOTICE file distributed with&lt;br /&gt;
 * this work for additional information regarding copyright ownership.&lt;br /&gt;
 * The ASF licenses this file to You under the Apache License, Version 2.0&lt;br /&gt;
 * (the &amp;quot;License&amp;quot;); you may not use this file except in compliance with&lt;br /&gt;
 * the License.  You may obtain a copy of the License at&lt;br /&gt;
 * &lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 * &lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
/* $Id: ASCII85OutputStream.java 426584 2006-07-28 16:01:47Z jeremias $ */&lt;br /&gt;
&lt;br /&gt;
import java.io.OutputStream;&lt;br /&gt;
import java.io.FilterOutputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
/**&lt;br /&gt;
 * This class applies a ASCII85 encoding to the stream.&lt;br /&gt;
 *&lt;br /&gt;
 * @version $Id: ASCII85OutputStream.java 426584 2006-07-28 16:01:47Z jeremias $&lt;br /&gt;
 */&lt;br /&gt;
public class ASCII85OutputStream extends FilterOutputStream&lt;br /&gt;
            implements ASCII85Constants {&lt;br /&gt;
    private static final boolean DEBUG = false;&lt;br /&gt;
    private int pos = 0;&lt;br /&gt;
    private long buffer = 0;&lt;br /&gt;
    private int posinline = 0;&lt;br /&gt;
    private int bw = 0;&lt;br /&gt;
    /** @see java.io.FilterOutputStream **/&lt;br /&gt;
    public ASCII85OutputStream(OutputStream out) {&lt;br /&gt;
        super(out);&lt;br /&gt;
    }&lt;br /&gt;
    /** @see java.io.FilterOutputStream **/&lt;br /&gt;
    public void write(int b) throws IOException {&lt;br /&gt;
        if (pos == 0) {&lt;br /&gt;
            buffer += (b &amp;lt;&amp;lt; 24) &amp;amp; 0xff000000L;&lt;br /&gt;
        } else if (pos == 1) {&lt;br /&gt;
            buffer += (b &amp;lt;&amp;lt; 16) &amp;amp; 0xff0000L;&lt;br /&gt;
        } else if (pos == 2) {&lt;br /&gt;
            buffer += (b &amp;lt;&amp;lt; 8) &amp;amp; 0xff00L;&lt;br /&gt;
        } else {&lt;br /&gt;
            buffer += b &amp;amp; 0xffL;&lt;br /&gt;
        }&lt;br /&gt;
        pos++;&lt;br /&gt;
        if (pos &amp;gt; 3) {&lt;br /&gt;
            checkedWrite(convertWord(buffer));&lt;br /&gt;
            buffer = 0;&lt;br /&gt;
            pos = 0;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /* UNUSED ATM&lt;br /&gt;
    private void checkedWrite(int b) throws IOException {&lt;br /&gt;
        if (posinline == 80) {&lt;br /&gt;
            out.write(EOL); bw++;&lt;br /&gt;
            posinline = 0;&lt;br /&gt;
        }&lt;br /&gt;
        checkedWrite(b);&lt;br /&gt;
        posinline++;&lt;br /&gt;
        bw++;&lt;br /&gt;
    }*/&lt;br /&gt;
    private void checkedWrite(byte[] buf) throws IOException {&lt;br /&gt;
        checkedWrite(buf, buf.length, false);&lt;br /&gt;
    }&lt;br /&gt;
    private void checkedWrite(byte[] buf, boolean nosplit) throws IOException {&lt;br /&gt;
        checkedWrite(buf, buf.length, nosplit);&lt;br /&gt;
    }&lt;br /&gt;
    private void checkedWrite(byte[] buf , int len) throws IOException {&lt;br /&gt;
        checkedWrite(buf, len, false);&lt;br /&gt;
    }&lt;br /&gt;
    private void checkedWrite(byte[] buf , int len, boolean nosplit) throws IOException {&lt;br /&gt;
        if (posinline + len &amp;gt; 80) {&lt;br /&gt;
            int firstpart = (nosplit ? 0 : len - (posinline + len - 80));&lt;br /&gt;
            if (firstpart &amp;gt; 0) {&lt;br /&gt;
                out.write(buf, 0, firstpart);&lt;br /&gt;
            }&lt;br /&gt;
            out.write(EOL); bw++;&lt;br /&gt;
            int rest = len - firstpart;&lt;br /&gt;
            if (rest &amp;gt; 0) {&lt;br /&gt;
                out.write(buf, firstpart, rest);&lt;br /&gt;
            }&lt;br /&gt;
            posinline = rest;&lt;br /&gt;
        } else {&lt;br /&gt;
            out.write(buf, 0, len);&lt;br /&gt;
            posinline += len;&lt;br /&gt;
        }&lt;br /&gt;
        bw += len;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * This converts a 32 bit value (4 bytes) into 5 bytes using base 85.&lt;br /&gt;
     * each byte in the result starts with zero at the &amp;quot;!&amp;quot; character so&lt;br /&gt;
     * the resulting base85 number fits into printable ascii chars&lt;br /&gt;
     *&lt;br /&gt;
     * @param word the 32 bit unsigned (hence the long datatype) word&lt;br /&gt;
     * @return 5 bytes (or a single byte of the &amp;quot;z&amp;quot; character for word&lt;br /&gt;
     * values of 0)&lt;br /&gt;
     */&lt;br /&gt;
    private byte[] convertWord(long word) {&lt;br /&gt;
        word = word &amp;amp; 0xffffffff;&lt;br /&gt;
        if (word == 0) {&lt;br /&gt;
            return ZERO_ARRAY;&lt;br /&gt;
        } else {&lt;br /&gt;
            if (word &amp;lt; 0) {&lt;br /&gt;
                word = -word;&lt;br /&gt;
            }&lt;br /&gt;
            byte c1 =&lt;br /&gt;
                (byte)((word&lt;br /&gt;
                        / POW85[0]) &amp;amp; 0xFF);&lt;br /&gt;
            byte c2 =&lt;br /&gt;
                (byte)(((word - (c1 * POW85[0]))&lt;br /&gt;
                        / POW85[1]) &amp;amp; 0xFF);&lt;br /&gt;
            byte c3 =&lt;br /&gt;
                (byte)(((word - (c1 * POW85[0])&lt;br /&gt;
                              - (c2 * POW85[1]))&lt;br /&gt;
                        / POW85[2]) &amp;amp; 0xFF);&lt;br /&gt;
            byte c4 =&lt;br /&gt;
                (byte)(((word - (c1 * POW85[0])&lt;br /&gt;
                              - (c2 * POW85[1])&lt;br /&gt;
                              - (c3 * POW85[2]))&lt;br /&gt;
                        / POW85[3]) &amp;amp; 0xFF);&lt;br /&gt;
            byte c5 =&lt;br /&gt;
                (byte)(((word - (c1 * POW85[0])&lt;br /&gt;
                              - (c2 * POW85[1])&lt;br /&gt;
                              - (c3 * POW85[2])&lt;br /&gt;
                              - (c4 * POW85[3])))&lt;br /&gt;
                        &amp;amp; 0xFF);&lt;br /&gt;
            byte[] ret = {&lt;br /&gt;
                (byte)(c1 + START), (byte)(c2 + START),&lt;br /&gt;
                (byte)(c3 + START), (byte)(c4 + START),&lt;br /&gt;
                (byte)(c5 + START)&lt;br /&gt;
            };&lt;br /&gt;
            if (DEBUG) {&lt;br /&gt;
                for (int i = 0; i &amp;lt; ret.length; i++) {&lt;br /&gt;
                    if (ret[i] &amp;lt; 33 || ret[i] &amp;gt; 117) {&lt;br /&gt;
                        System.out.println(&amp;quot;Illegal char value &amp;quot;&lt;br /&gt;
                                        + new Integer(ret[i]));&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            return ret;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /** @see Finalizable **/&lt;br /&gt;
    public void finalizeStream() throws IOException {&lt;br /&gt;
        // now take care of the trailing few bytes.&lt;br /&gt;
        // with n leftover bytes, we append 0 bytes to make a full group of 4&lt;br /&gt;
        // then convert like normal (except not applying the special zero rule)&lt;br /&gt;
        // and write out the first n+1 bytes from the result&lt;br /&gt;
        if (pos &amp;gt; 0) {&lt;br /&gt;
            int rest = pos;&lt;br /&gt;
            /*&lt;br /&gt;
            byte[] lastdata = new byte[4];&lt;br /&gt;
            int i = 0;&lt;br /&gt;
            for (int j = 0; j &amp;lt; 4; j++) {&lt;br /&gt;
                if (j &amp;lt; rest) {&lt;br /&gt;
                    lastdata[j] = data[i++];&lt;br /&gt;
                } else {&lt;br /&gt;
                    lastdata[j] = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            long val = ((lastdata[0] &amp;lt;&amp;lt; 24) &amp;amp; 0xff000000L)&lt;br /&gt;
                       + ((lastdata[1] &amp;lt;&amp;lt; 16) &amp;amp; 0xff0000L)&lt;br /&gt;
                       + ((lastdata[2] &amp;lt;&amp;lt; 8) &amp;amp; 0xff00L)&lt;br /&gt;
                       + (lastdata[3] &amp;amp; 0xffL);&lt;br /&gt;
            */&lt;br /&gt;
            byte[] conv;&lt;br /&gt;
            // special rule for handling zeros at the end&lt;br /&gt;
            if (buffer != 0) {&lt;br /&gt;
                conv = convertWord(buffer);&lt;br /&gt;
            } else {&lt;br /&gt;
                conv = new byte[5];&lt;br /&gt;
                for (int j = 0; j &amp;lt; 5; j++) {&lt;br /&gt;
                    conv[j] = (byte)&amp;quot;!&amp;quot;;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            // assert rest+1 &amp;lt;= 5&lt;br /&gt;
            checkedWrite(conv, rest + 1);&lt;br /&gt;
        }&lt;br /&gt;
        // finally write the two character end of data marker&lt;br /&gt;
        checkedWrite(EOD, true);&lt;br /&gt;
        flush();&lt;br /&gt;
  &lt;br /&gt;
    }&lt;br /&gt;
    /** @see java.io.FilterOutputStream **/&lt;br /&gt;
    public void close() throws IOException {&lt;br /&gt;
        finalizeStream();&lt;br /&gt;
        super.close();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one or more&lt;br /&gt;
 * contributor license agreements.  See the NOTICE file distributed with&lt;br /&gt;
 * this work for additional information regarding copyright ownership.&lt;br /&gt;
 * The ASF licenses this file to You under the Apache License, Version 2.0&lt;br /&gt;
 * (the &amp;quot;License&amp;quot;); you may not use this file except in compliance with&lt;br /&gt;
 * the License.  You may obtain a copy of the License at&lt;br /&gt;
 * &lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 * &lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
/* $Id: ASCII85Constants.java 426584 2006-07-28 16:01:47Z jeremias $ */&lt;br /&gt;
 &lt;br /&gt;
/**&lt;br /&gt;
 * This interface defines constants used by the ASCII85 filters.&lt;br /&gt;
 *&lt;br /&gt;
 * @version $Id: ASCII85Constants.java 426584 2006-07-28 16:01:47Z jeremias $&lt;br /&gt;
 */&lt;br /&gt;
interface ASCII85Constants {&lt;br /&gt;
    /** Special character &amp;quot;z&amp;quot; stands for four NULL bytes (short-cut for !!!!!) */&lt;br /&gt;
    public static final int ZERO          = 0x7A; //&amp;quot;z&amp;quot;&lt;br /&gt;
    /** ZERO as a byte array */&lt;br /&gt;
    public static final byte[] ZERO_ARRAY = {(byte)ZERO};&lt;br /&gt;
    /** The start index for ASCII85 characters (!) */&lt;br /&gt;
    public static final int START         = 0x21; //&amp;quot;!&amp;quot;&lt;br /&gt;
    /** The end index for ASCII85 characters (u) */&lt;br /&gt;
    public static final int END           = 0x75; //&amp;quot;u&amp;quot;&lt;br /&gt;
    /** The EOL indicator (LF) */&lt;br /&gt;
    public static final int EOL           = 0x0A; //&amp;quot;\n&amp;quot;&lt;br /&gt;
    /** The EOD (end of data) indicator */&lt;br /&gt;
    public static final byte[] EOD        = {0x7E, 0x3E}; //&amp;quot;~&amp;gt;&amp;quot;&lt;br /&gt;
    /** Array of powers of 85 (4, 3, 2, 1, 0) */&lt;br /&gt;
    public static final long POW85[] = new long[] {85 * 85 * 85 * 85, &lt;br /&gt;
                                                    85 * 85 * 85,&lt;br /&gt;
                                                    85 * 85,&lt;br /&gt;
                                                    85,&lt;br /&gt;
                                                    1};&lt;br /&gt;
    /*&lt;br /&gt;
    public static final long BASE85_4 = 85;&lt;br /&gt;
    public static final long BASE85_3 = BASE85_4 * BASE85_4;&lt;br /&gt;
    public static final long BASE85_2 = BASE85_3 * BASE85_4;&lt;br /&gt;
    public static final long BASE85_1 = BASE85_2 * BASE85_4;&lt;br /&gt;
    */&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ASCII Utility ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
     &lt;br /&gt;
import java.io.ByteArrayInputStream;&lt;br /&gt;
import java.io.ByteArrayOutputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
/*&lt;br /&gt;
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * The contents of this file are subject to the terms of either the GNU&lt;br /&gt;
 * General Public License Version 2 only (&amp;quot;GPL&amp;quot;) or the Common Development&lt;br /&gt;
 * and Distribution License(&amp;quot;CDDL&amp;quot;) (collectively, the &amp;quot;License&amp;quot;).  You&lt;br /&gt;
 * may not use this file except in compliance with the License. You can obtain&lt;br /&gt;
 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html&lt;br /&gt;
 * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific&lt;br /&gt;
 * language governing permissions and limitations under the License.&lt;br /&gt;
 *&lt;br /&gt;
 * When distributing the software, include this License Header Notice in each&lt;br /&gt;
 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.&lt;br /&gt;
 * Sun designates this particular file as subject to the &amp;quot;Classpath&amp;quot; exception&lt;br /&gt;
 * as provided by Sun in the GPL Version 2 section of the License file that&lt;br /&gt;
 * accompanied this code.  If applicable, add the following below the License&lt;br /&gt;
 * Header, with the fields enclosed by brackets [] replaced by your own&lt;br /&gt;
 * identifying information: &amp;quot;Portions Copyrighted [year]&lt;br /&gt;
 * [name of copyright owner]&amp;quot;&lt;br /&gt;
 *&lt;br /&gt;
 * Contributor(s):&lt;br /&gt;
 *&lt;br /&gt;
 * If you wish your version of this file to be governed by only the CDDL or&lt;br /&gt;
 * only the GPL Version 2, indicate your decision by adding &amp;quot;[Contributor]&lt;br /&gt;
 * elects to include this software in this distribution under the [CDDL or GPL&lt;br /&gt;
 * Version 2] license.&amp;quot;  If you don&amp;quot;t indicate a single choice of license, a&lt;br /&gt;
 * recipient has the option to distribute your version of this file under&lt;br /&gt;
 * either the CDDL, the GPL Version 2 or to extend the choice of license to&lt;br /&gt;
 * its licensees as provided above.  However, if you add GPL Version 2 code&lt;br /&gt;
 * and therefore, elected the GPL Version 2 license, then the option applies&lt;br /&gt;
 * only if the new code is made subject to such option by the copyright&lt;br /&gt;
 * holder.&lt;br /&gt;
 */&lt;br /&gt;
/*&lt;br /&gt;
 * @(#)ASCIIUtility.java  1.11 07/05/04&lt;br /&gt;
 */&lt;br /&gt;
 class ASCIIUtility {&lt;br /&gt;
    // Private constructor so that this class is not instantiated&lt;br /&gt;
    private ASCIIUtility() { }&lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * Convert the bytes within the specified range of the given byte &lt;br /&gt;
     * array into a signed integer in the given radix . The range extends &lt;br /&gt;
     * from &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; till, but not including &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;. &amp;lt;p&amp;gt;&lt;br /&gt;
     *&lt;br /&gt;
     * Based on java.lang.Integer.parseInt()&lt;br /&gt;
     */&lt;br /&gt;
    public static int parseInt(byte[] b, int start, int end, int radix)&lt;br /&gt;
    throws NumberFormatException {&lt;br /&gt;
  if (b == null)&lt;br /&gt;
      throw new NumberFormatException(&amp;quot;null&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  int result = 0;&lt;br /&gt;
  boolean negative = false;&lt;br /&gt;
  int i = start;&lt;br /&gt;
  int limit;&lt;br /&gt;
  int multmin;&lt;br /&gt;
  int digit;&lt;br /&gt;
  if (end &amp;gt; start) {&lt;br /&gt;
      if (b[i] == &amp;quot;-&amp;quot;) {&lt;br /&gt;
    negative = true;&lt;br /&gt;
    limit = Integer.MIN_VALUE;&lt;br /&gt;
    i++;&lt;br /&gt;
      } else {&lt;br /&gt;
    limit = -Integer.MAX_VALUE;&lt;br /&gt;
      }&lt;br /&gt;
      multmin = limit / radix;&lt;br /&gt;
      if (i &amp;lt; end) {&lt;br /&gt;
    digit = Character.digit((char)b[i++], radix);&lt;br /&gt;
    if (digit &amp;lt; 0) {&lt;br /&gt;
        throw new NumberFormatException(&lt;br /&gt;
      &amp;quot;illegal number: &amp;quot; + toString(b, start, end)&lt;br /&gt;
      );&lt;br /&gt;
    } else {&lt;br /&gt;
        result = -digit;&lt;br /&gt;
    }&lt;br /&gt;
      }&lt;br /&gt;
      while (i &amp;lt; end) {&lt;br /&gt;
    // Accumulating negatively avoids surprises near MAX_VALUE&lt;br /&gt;
    digit = Character.digit((char)b[i++], radix);&lt;br /&gt;
    if (digit &amp;lt; 0) {&lt;br /&gt;
        throw new NumberFormatException(&amp;quot;illegal number&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    if (result &amp;lt; multmin) {&lt;br /&gt;
        throw new NumberFormatException(&amp;quot;illegal number&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    result *= radix;&lt;br /&gt;
    if (result &amp;lt; limit + digit) {&lt;br /&gt;
        throw new NumberFormatException(&amp;quot;illegal number&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    result -= digit;&lt;br /&gt;
      }&lt;br /&gt;
  } else {&lt;br /&gt;
      throw new NumberFormatException(&amp;quot;illegal number&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  if (negative) {&lt;br /&gt;
      if (i &amp;gt; start + 1) {&lt;br /&gt;
    return result;&lt;br /&gt;
      } else {  /* Only got &amp;quot;-&amp;quot; */&lt;br /&gt;
    throw new NumberFormatException(&amp;quot;illegal number&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
  } else {&lt;br /&gt;
      return -result;&lt;br /&gt;
  }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Convert the bytes within the specified range of the given byte &lt;br /&gt;
     * array into a signed integer . The range extends from &lt;br /&gt;
     * &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; till, but not including &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;. &amp;lt;p&amp;gt;&lt;br /&gt;
     */&lt;br /&gt;
    public static int parseInt(byte[] b, int start, int end)&lt;br /&gt;
    throws NumberFormatException {&lt;br /&gt;
  return parseInt(b, start, end, 10);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Convert the bytes within the specified range of the given byte &lt;br /&gt;
     * array into a signed long in the given radix . The range extends &lt;br /&gt;
     * from &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; till, but not including &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;. &amp;lt;p&amp;gt;&lt;br /&gt;
     *&lt;br /&gt;
     * Based on java.lang.Long.parseLong()&lt;br /&gt;
     */&lt;br /&gt;
    public static long parseLong(byte[] b, int start, int end, int radix)&lt;br /&gt;
    throws NumberFormatException {&lt;br /&gt;
  if (b == null)&lt;br /&gt;
      throw new NumberFormatException(&amp;quot;null&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  long result = 0;&lt;br /&gt;
  boolean negative = false;&lt;br /&gt;
  int i = start;&lt;br /&gt;
  long limit;&lt;br /&gt;
  long multmin;&lt;br /&gt;
  int digit;&lt;br /&gt;
  if (end &amp;gt; start) {&lt;br /&gt;
      if (b[i] == &amp;quot;-&amp;quot;) {&lt;br /&gt;
    negative = true;&lt;br /&gt;
    limit = Long.MIN_VALUE;&lt;br /&gt;
    i++;&lt;br /&gt;
      } else {&lt;br /&gt;
    limit = -Long.MAX_VALUE;&lt;br /&gt;
      }&lt;br /&gt;
      multmin = limit / radix;&lt;br /&gt;
      if (i &amp;lt; end) {&lt;br /&gt;
    digit = Character.digit((char)b[i++], radix);&lt;br /&gt;
    if (digit &amp;lt; 0) {&lt;br /&gt;
        throw new NumberFormatException(&lt;br /&gt;
      &amp;quot;illegal number: &amp;quot; + toString(b, start, end)&lt;br /&gt;
      );&lt;br /&gt;
    } else {&lt;br /&gt;
        result = -digit;&lt;br /&gt;
    }&lt;br /&gt;
      }&lt;br /&gt;
      while (i &amp;lt; end) {&lt;br /&gt;
    // Accumulating negatively avoids surprises near MAX_VALUE&lt;br /&gt;
    digit = Character.digit((char)b[i++], radix);&lt;br /&gt;
    if (digit &amp;lt; 0) {&lt;br /&gt;
        throw new NumberFormatException(&amp;quot;illegal number&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    if (result &amp;lt; multmin) {&lt;br /&gt;
        throw new NumberFormatException(&amp;quot;illegal number&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    result *= radix;&lt;br /&gt;
    if (result &amp;lt; limit + digit) {&lt;br /&gt;
        throw new NumberFormatException(&amp;quot;illegal number&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    result -= digit;&lt;br /&gt;
      }&lt;br /&gt;
  } else {&lt;br /&gt;
      throw new NumberFormatException(&amp;quot;illegal number&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  if (negative) {&lt;br /&gt;
      if (i &amp;gt; start + 1) {&lt;br /&gt;
    return result;&lt;br /&gt;
      } else {  /* Only got &amp;quot;-&amp;quot; */&lt;br /&gt;
    throw new NumberFormatException(&amp;quot;illegal number&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
  } else {&lt;br /&gt;
      return -result;&lt;br /&gt;
  }&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Convert the bytes within the specified range of the given byte &lt;br /&gt;
     * array into a signed long . The range extends from &lt;br /&gt;
     * &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; till, but not including &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;. &amp;lt;p&amp;gt;&lt;br /&gt;
     */&lt;br /&gt;
    public static long parseLong(byte[] b, int start, int end)&lt;br /&gt;
    throws NumberFormatException {&lt;br /&gt;
  return parseLong(b, start, end, 10);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Convert the bytes within the specified range of the given byte &lt;br /&gt;
     * array into a String. The range extends from &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt;&lt;br /&gt;
     * till, but not including &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;. &amp;lt;p&amp;gt;&lt;br /&gt;
     */&lt;br /&gt;
    public static String toString(byte[] b, int start, int end) {&lt;br /&gt;
  int size = end - start;&lt;br /&gt;
  char[] theChars = new char[size];&lt;br /&gt;
  for (int i = 0, j = start; i &amp;lt; size; )&lt;br /&gt;
      theChars[i++] = (char)(b[j++]&amp;amp;0xff);&lt;br /&gt;
  &lt;br /&gt;
  return new String(theChars);&lt;br /&gt;
    }&lt;br /&gt;
    public static String toString(ByteArrayInputStream is) {&lt;br /&gt;
  int size = is.available();&lt;br /&gt;
  char[] theChars = new char[size];&lt;br /&gt;
  byte[] bytes    = new byte[size];&lt;br /&gt;
  is.read(bytes, 0, size);&lt;br /&gt;
  for (int i = 0; i &amp;lt; size;)&lt;br /&gt;
      theChars[i] = (char)(bytes[i++]&amp;amp;0xff);&lt;br /&gt;
  &lt;br /&gt;
  return new String(theChars);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public static byte[] getBytes(String s) {&lt;br /&gt;
  char [] chars= s.toCharArray();&lt;br /&gt;
  int size = chars.length;&lt;br /&gt;
  byte[] bytes = new byte[size];&lt;br /&gt;
      &lt;br /&gt;
  for (int i = 0; i &amp;lt; size;)&lt;br /&gt;
      bytes[i] = (byte) chars[i++];&lt;br /&gt;
  return bytes;&lt;br /&gt;
    }&lt;br /&gt;
    public static byte[] getBytes(InputStream is) throws IOException {&lt;br /&gt;
  int len;&lt;br /&gt;
  int size = 1024;&lt;br /&gt;
  byte [] buf;&lt;br /&gt;
&lt;br /&gt;
  if (is instanceof ByteArrayInputStream) {&lt;br /&gt;
      size = is.available();&lt;br /&gt;
      buf = new byte[size];&lt;br /&gt;
      len = is.read(buf, 0, size);&lt;br /&gt;
  }&lt;br /&gt;
  else {&lt;br /&gt;
      ByteArrayOutputStream bos = new ByteArrayOutputStream();&lt;br /&gt;
      buf = new byte[size];&lt;br /&gt;
      while ((len = is.read(buf, 0, size)) != -1)&lt;br /&gt;
    bos.write(buf, 0, len);&lt;br /&gt;
      buf = bos.toByteArray();&lt;br /&gt;
  }&lt;br /&gt;
  return buf;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Display the ISO Latin-1 character set ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
public class LatinSet {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    System.out.println(&amp;quot;ISO LATIN-1 CHARACTER SET&amp;quot;);&lt;br /&gt;
    for (int x = 160; x &amp;lt; 255; x++) {&lt;br /&gt;
      System.out.print((char) x);&lt;br /&gt;
      System.out.print(&amp;quot;  &amp;quot;);&lt;br /&gt;
      if (x % 8 == 7)&lt;br /&gt;
        System.out.print(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading CRLF terminated lines that contain only US-ASCII characters from an input stream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
import java.io.*;&lt;br /&gt;
/**&lt;br /&gt;
 * This class is to support reading CRLF terminated lines that&lt;br /&gt;
 * contain only US-ASCII characters from an input stream. Provides&lt;br /&gt;
 * functionality that is similar to the deprecated &lt;br /&gt;
 * &amp;lt;code&amp;gt;DataInputStream.readLine()&amp;lt;/code&amp;gt;. Expected use is to read&lt;br /&gt;
 * lines as String objects from a RFC822 stream.&lt;br /&gt;
 *&lt;br /&gt;
 * It is implemented as a FilterInputStream, so one can just wrap &lt;br /&gt;
 * this class around any input stream and read bytes from this filter.&lt;br /&gt;
 * &lt;br /&gt;
 * @author John Mani&lt;br /&gt;
 */&lt;br /&gt;
public class LineInputStream extends FilterInputStream {&lt;br /&gt;
    private char[] lineBuffer = null; // reusable byte buffer&lt;br /&gt;
    public LineInputStream(InputStream in) {&lt;br /&gt;
  super(in);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Read a line containing only ASCII characters from the input &lt;br /&gt;
     * stream. A line is terminated by a CR or NL or CR-NL sequence.&lt;br /&gt;
     * A common error is a CR-CR-NL sequence, which will also terminate&lt;br /&gt;
     * a line.&lt;br /&gt;
     * The line terminator is not returned as part of the returned &lt;br /&gt;
     * String. Returns null if no data is available. &amp;lt;p&amp;gt;&lt;br /&gt;
     *&lt;br /&gt;
     * This class is similar to the deprecated &lt;br /&gt;
     * &amp;lt;code&amp;gt;DataInputStream.readLine()&amp;lt;/code&amp;gt;&lt;br /&gt;
     */&lt;br /&gt;
    public String readLine() throws IOException {&lt;br /&gt;
  InputStream in = this.in;&lt;br /&gt;
  char[] buf = lineBuffer;&lt;br /&gt;
  if (buf == null)&lt;br /&gt;
      buf = lineBuffer = new char[128];&lt;br /&gt;
  int c1;&lt;br /&gt;
  int room = buf.length;&lt;br /&gt;
  int offset = 0;&lt;br /&gt;
  while ((c1 = in.read()) != -1) {&lt;br /&gt;
      if (c1 == &amp;quot;\n&amp;quot;) // Got NL, outa here.&lt;br /&gt;
    break;&lt;br /&gt;
      else if (c1 == &amp;quot;\r&amp;quot;) {&lt;br /&gt;
    // Got CR, is the next char NL ?&lt;br /&gt;
    int c2 = in.read();&lt;br /&gt;
    if (c2 == &amp;quot;\r&amp;quot;)   // discard extraneous CR&lt;br /&gt;
        c2 = in.read();&lt;br /&gt;
    if (c2 != &amp;quot;\n&amp;quot;) {&lt;br /&gt;
        // If not NL, push it back&lt;br /&gt;
        if (!(in instanceof PushbackInputStream))&lt;br /&gt;
      in = this.in = new PushbackInputStream(in);&lt;br /&gt;
        ((PushbackInputStream)in).unread(c2);&lt;br /&gt;
    }&lt;br /&gt;
    break; // outa here.&lt;br /&gt;
      }&lt;br /&gt;
      // Not CR, NL or CR-NL ...&lt;br /&gt;
      // .. Insert the byte into our byte buffer&lt;br /&gt;
      if (--room &amp;lt; 0) { // No room, need to grow.&lt;br /&gt;
    buf = new char[offset + 128];&lt;br /&gt;
    room = buf.length - offset - 1;&lt;br /&gt;
    System.arraycopy(lineBuffer, 0, buf, 0, offset);&lt;br /&gt;
    lineBuffer = buf;&lt;br /&gt;
      }&lt;br /&gt;
      buf[offset++] = (char)c1;&lt;br /&gt;
  }&lt;br /&gt;
  if ((c1 == -1) &amp;amp;&amp;amp; (offset == 0))&lt;br /&gt;
      return null;&lt;br /&gt;
  &lt;br /&gt;
  return String.copyValueOf(buf, 0, offset);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>