Java Code Examples for java.io.PushbackInputStream#read()

The following examples show how to use java.io.PushbackInputStream#read() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UUDecoder.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Find the end of the line for the next operation.
 * The following sequences are recognized as end-of-line
 * CR, CR LF, or LF
 */
protected void decodeLineSuffix(PushbackInputStream inStream, OutputStream outStream) throws IOException {
    int c;
    while (true) {
        c = inStream.read();
        if (c == -1) {
            throw new CEStreamExhausted();
        }
        if (c == '\n') {
            break;
        }
        if (c == '\r') {
            c = inStream.read();
            if ((c != '\n') && (c != -1)) {
                inStream.unread (c);
            }
            break;
        }
    }
}
 
Example 2
Source File: UUDecoder.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Decode a UU atom. Note that if l is less than 3 we don't write
 * the extra bits, however the encoder always encodes 4 character
 * groups even when they are not needed.
 */
protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int l)
    throws IOException {
    int i, c1, c2, c3, c4;
    int a, b, c;
    StringBuffer x = new StringBuffer();

    for (i = 0; i < 4; i++) {
        c1 = inStream.read();
        if (c1 == -1) {
            throw new CEStreamExhausted();
        }
        x.append((char)c1);
        decoderBuffer[i] = (byte) ((c1 - ' ') & 0x3f);
    }
    a = ((decoderBuffer[0] << 2) & 0xfc) | ((decoderBuffer[1] >>> 4) & 3);
    b = ((decoderBuffer[1] << 4) & 0xf0) | ((decoderBuffer[2] >>> 2) & 0xf);
    c = ((decoderBuffer[2] << 6) & 0xc0) | (decoderBuffer[3] & 0x3f);
    outStream.write((byte)(a & 0xff));
    if (l > 1) {
        outStream.write((byte)( b & 0xff));
    }
    if (l > 2) {
        outStream.write((byte)(c&0xff));
    }
}
 
Example 3
Source File: UUDecoder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * In uuencoded buffers, encoded lines start with a character that
 * represents the number of bytes encoded in this line. The last
 * line of input is always a line that starts with a single space
 * character, which would be a zero length line.
 */
protected int decodeLinePrefix(PushbackInputStream inStream, OutputStream outStream) throws IOException {
    int     c;

    c = inStream.read();
    if (c == ' ') {
        c = inStream.read(); /* discard the (first)trailing CR or LF  */
        c = inStream.read(); /* check for a second one  */
        if ((c != '\n') && (c != -1))
            inStream.unread (c);
        throw new CEStreamExhausted();
    } else if (c == -1) {
        throw new CEFormatException("UUDecoder: Short Buffer.");
    }

    c = (c - ' ') & 0x3f;
    if (c > bytesPerLine()) {
        throw new CEFormatException("UUDecoder: Bad Line Length.");
    }
    return (c);
}
 
Example 4
Source File: ServerAuthenticatorBase.java    From T0rlib4Android with Apache License 2.0 6 votes vote down vote up
/**
 * Grants access to everyone.Removes authentication related bytes from the
 * stream, when a SOCKS5 connection is being made, selects an authentication
 * NONE.
 */
public ServerAuthenticator startSession(Socket s) throws IOException {

	final PushbackInputStream in = new PushbackInputStream(s
			.getInputStream());
	final OutputStream out = s.getOutputStream();

	final int version = in.read();
	if (version == 5) {
		if (!selectSocks5Authentication(in, out, 0)) {
			return null;
		}
	} else if (version == 4) {
		// Else it is the request message already, version 4
		in.unread(version);
	} else {
		return null;
	}

	return new ServerAuthenticatorNone(in, out);
}
 
Example 5
Source File: UUDecoder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Decode a UU atom. Note that if l is less than 3 we don't write
 * the extra bits, however the encoder always encodes 4 character
 * groups even when they are not needed.
 */
protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int l)
    throws IOException {
    int i, c1, c2, c3, c4;
    int a, b, c;
    StringBuffer x = new StringBuffer();

    for (i = 0; i < 4; i++) {
        c1 = inStream.read();
        if (c1 == -1) {
            throw new CEStreamExhausted();
        }
        x.append((char)c1);
        decoderBuffer[i] = (byte) ((c1 - ' ') & 0x3f);
    }
    a = ((decoderBuffer[0] << 2) & 0xfc) | ((decoderBuffer[1] >>> 4) & 3);
    b = ((decoderBuffer[1] << 4) & 0xf0) | ((decoderBuffer[2] >>> 2) & 0xf);
    c = ((decoderBuffer[2] << 6) & 0xc0) | (decoderBuffer[3] & 0x3f);
    outStream.write((byte)(a & 0xff));
    if (l > 1) {
        outStream.write((byte)( b & 0xff));
    }
    if (l > 2) {
        outStream.write((byte)(c&0xff));
    }
}
 
Example 6
Source File: UUDecoder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find the end of the line for the next operation.
 * The following sequences are recognized as end-of-line
 * CR, CR LF, or LF
 */
protected void decodeLineSuffix(PushbackInputStream inStream, OutputStream outStream) throws IOException {
    int c;
    while (true) {
        c = inStream.read();
        if (c == -1) {
            throw new CEStreamExhausted();
        }
        if (c == '\n') {
            break;
        }
        if (c == '\r') {
            c = inStream.read();
            if ((c != '\n') && (c != -1)) {
                inStream.unread (c);
            }
            break;
        }
    }
}
 
Example 7
Source File: UUDecoder.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find the end of the line for the next operation.
 * The following sequences are recognized as end-of-line
 * CR, CR LF, or LF
 */
protected void decodeLineSuffix(PushbackInputStream inStream, OutputStream outStream) throws IOException {
    int c;
    while (true) {
        c = inStream.read();
        if (c == -1) {
            throw new CEStreamExhausted();
        }
        if (c == '\n') {
            break;
        }
        if (c == '\r') {
            c = inStream.read();
            if ((c != '\n') && (c != -1)) {
                inStream.unread (c);
            }
            break;
        }
    }
}
 
Example 8
Source File: UUDecoder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * UUencoded files have a buffer suffix which consists of the word
 * end. This line should immediately follow the line with a single
 * space in it.
 */
protected void decodeBufferSuffix(PushbackInputStream inStream, OutputStream outStream) throws IOException  {
    int     c;

    c = inStream.read(decoderBuffer);
    if ((decoderBuffer[0] != 'e') || (decoderBuffer[1] != 'n') ||
        (decoderBuffer[2] != 'd')) {
        throw new CEFormatException("UUDecoder: Missing 'end' line.");
    }
}
 
Example 9
Source File: UCDecoder.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * decodeLinePrefix reads the sequence number and the number of
 * encoded bytes from the line. If the sequence number is not the
 * previous sequence number + 1 then an exception is thrown.
 * UCE lines are line terminator immune, they all start with *
 * so the other thing this method does is scan for the next line
 * by looking for the * character.
 *
 * @exception CEFormatException out of sequence lines detected.
 */
protected int decodeLinePrefix(PushbackInputStream inStream, OutputStream outStream)  throws IOException {
    int     i;
    int     nLen, nSeq;
    byte    xtmp[];
    int     c;

    crc.value = 0;
    while (true) {
        c = inStream.read(tmp, 0, 1);
        if (c == -1) {
            throw new CEStreamExhausted();
        }
        if (tmp[0] == '*') {
            break;
        }
    }
    lineAndSeq.reset();
    decodeAtom(inStream, lineAndSeq, 2);
    xtmp = lineAndSeq.toByteArray();
    nLen = xtmp[0] & 0xff;
    nSeq = xtmp[1] & 0xff;
    if (nSeq != sequence) {
        throw new CEFormatException("UCDecoder: Out of sequence line.");
    }
    sequence = (sequence + 1) & 0xff;
    return (nLen);
}
 
Example 10
Source File: JTMEncodingSniffer.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
public String guessEncoding(PushbackInputStream stream) throws IOException {
  // http://www.ietf.org/rfc/rfc4627.txt requires that a JSON data stream
  // has to be in UTF notation. This code checks which specific UTF format
  // is being used.

  String encoding = "UTF8";
  
  byte[] buffer = new byte[4];
  int bytesread = stream.read(buffer, 0, 4);    
  if (bytesread == 4) {
    // check for the different UTF formats:
    //
    // 00 00 00 xx  UTF-32BE
    // 00 xx 00 xx  UTF-16BE
    // xx 00 00 00  UTF-32LE
    // xx 00 xx 00  UTF-16LE
    // xx xx xx xx  UTF-8

    // Note: UTF32 is not supported by Java
    // http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html
    
    if (buffer[0] == (byte) 0x00 &&
        buffer[1] != (byte) 0x00 &&
        buffer[2] == (byte) 0x00 &&
        buffer[3] != (byte) 0x00) {
      encoding = "UnicodeBigUnmarked";
    } else if (buffer[0] != (byte) 0x00 &&
        buffer[1] == (byte) 0x00 &&
        buffer[2] != (byte) 0x00 &&
        buffer[3] == (byte) 0x00) {
      encoding = "UnicodeLittleUnmarked";
    }
  } 

  stream.unread(buffer, 0, bytesread);
  return encoding;
}
 
Example 11
Source File: CompactParseable.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static private String detectEncoding(PushbackInputStream in) throws IOException {
  String encoding = UTF8;
  int b1 = in.read();
  if (b1 != -1) {
    int b2 = in.read();
    if (b2 != -1) {
      in.unread(b2);
      if ((b1 == 0xFF && b2 == 0xFE) || (b1 == 0xFE && b2 == 0xFF))
        encoding = UTF16;
    }
    in.unread(b1);
  }
  return encoding;
}
 
Example 12
Source File: UCDecoder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * decodeLinePrefix reads the sequence number and the number of
 * encoded bytes from the line. If the sequence number is not the
 * previous sequence number + 1 then an exception is thrown.
 * UCE lines are line terminator immune, they all start with *
 * so the other thing this method does is scan for the next line
 * by looking for the * character.
 *
 * @exception CEFormatException out of sequence lines detected.
 */
protected int decodeLinePrefix(PushbackInputStream inStream, OutputStream outStream)  throws IOException {
    int     i;
    int     nLen, nSeq;
    byte    xtmp[];
    int     c;

    crc.value = 0;
    while (true) {
        c = inStream.read(tmp, 0, 1);
        if (c == -1) {
            throw new CEStreamExhausted();
        }
        if (tmp[0] == '*') {
            break;
        }
    }
    lineAndSeq.reset();
    decodeAtom(inStream, lineAndSeq, 2);
    xtmp = lineAndSeq.toByteArray();
    nLen = xtmp[0] & 0xff;
    nSeq = xtmp[1] & 0xff;
    if (nSeq != sequence) {
        throw new CEFormatException("UCDecoder: Out of sequence line.");
    }
    sequence = (sequence + 1) & 0xff;
    return (nLen);
}
 
Example 13
Source File: UUDecoder.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * UUencoded files have a buffer suffix which consists of the word
 * end. This line should immediately follow the line with a single
 * space in it.
 */
protected void decodeBufferSuffix(PushbackInputStream inStream, OutputStream outStream) throws IOException  {
    int     c;

    c = inStream.read(decoderBuffer);
    if ((decoderBuffer[0] != 'e') || (decoderBuffer[1] != 'n') ||
        (decoderBuffer[2] != 'd')) {
        throw new CEFormatException("UUDecoder: Missing 'end' line.");
    }
}
 
Example 14
Source File: HttpResponse.java    From nutch-htmlunit with Apache License 2.0 5 votes vote down vote up
private static int readLine(PushbackInputStream in, StringBuffer line, boolean allowContinuedLine)
        throws IOException {
    line.setLength(0);
    for (int c = in.read(); c != -1; c = in.read()) {
        switch (c) {
        case '\r':
            if (peek(in) == '\n') {
                in.read();
            }
        case '\n':
            if (line.length() > 0) {
                // at EOL -- check for continued line if the current
                // (possibly continued) line wasn't blank
                if (allowContinuedLine)
                    switch (peek(in)) {
                    case ' ':
                    case '\t': // line is continued
                        in.read();
                        continue;
                    }
            }
            return line.length(); // else complete
        default:
            line.append((char) c);
        }
    }
    throw new EOFException();
}
 
Example 15
Source File: UnicodeReader.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
/**
 * Construct UnicodeReader
 * @param in Input stream.
 * @param defaultEncoding Default encoding to be used if BOM is not found,
 * or <code>null</code> to use system default encoding.
 * @throws IOException If an I/O error occurs.
 */
public UnicodeReader(InputStream in, String defaultEncoding) throws IOException {
    byte[] bom = new byte[BOM_SIZE];
    String encoding;
    int unread;
    PushbackInputStream pushbackStream = new PushbackInputStream(in, BOM_SIZE);
    int n = pushbackStream.read(bom, 0, bom.length);

    // Read ahead four bytes and check for BOM marks.
    if ((bom[0] == (byte) 0xEF) && (bom[1] == (byte) 0xBB) && (bom[2] == (byte) 0xBF)) {
        encoding = "UTF-8";
        unread = n - 3;
    } else if ((bom[0] == (byte) 0xFE) && (bom[1] == (byte) 0xFF)) {
        encoding = "UTF-16BE";
        unread = n - 2;
    } else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE)) {
        encoding = "UTF-16LE";
        unread = n - 2;
    } else if ((bom[0] == (byte) 0x00) && (bom[1] == (byte) 0x00) && (bom[2] == (byte) 0xFE) && (bom[3] == (byte) 0xFF)) {
        encoding = "UTF-32BE";
        unread = n - 4;
    } else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE) && (bom[2] == (byte) 0x00) && (bom[3] == (byte) 0x00)) {
        encoding = "UTF-32LE";
        unread = n - 4;
    } else {
        encoding = defaultEncoding;
        unread = n;
    }

    // Unread bytes if necessary and skip BOM marks.
    if (unread > 0) {
        pushbackStream.unread(bom, n - unread, unread);
    } else if (unread < -1) {
        pushbackStream.unread(bom, 0, 0);
    }

    // Use given encoding.
    reader = encoding == null ? new InputStreamReader(pushbackStream) : new InputStreamReader(pushbackStream, encoding);
}
 
Example 16
Source File: UCDecoder.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Decode one atom - reads the characters from the input stream, decodes
 * them, and checks for valid parity.
 */
protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int l) throws IOException {
    int i, p1, p2, np1, np2;
    byte a = -1, b = -1, c = -1;
    byte high_byte, low_byte;
    byte tmp[] = new byte[3];

    i = inStream.read(tmp);
    if (i != 3) {
            throw new CEStreamExhausted();
    }
    for (i = 0; (i < 64) && ((a == -1) || (b == -1) || (c == -1)); i++) {
        if (tmp[0] == map_array[i]) {
            a = (byte) i;
        }
        if (tmp[1] == map_array[i]) {
            b = (byte) i;
        }
        if (tmp[2] == map_array[i]) {
            c = (byte) i;
        }
    }
    high_byte = (byte) (((a & 0x38) << 2) + (b & 0x1f));
    low_byte = (byte) (((a & 0x7) << 5) + (c & 0x1f));
    p1 = 0;
    p2 = 0;
    for (i = 1; i < 256; i = i * 2) {
        if ((high_byte & i) != 0)
            p1++;
        if ((low_byte & i) != 0)
            p2++;
    }
    np1 = (b & 32) / 32;
    np2 = (c & 32) / 32;
    if ((p1 & 1) != np1) {
        throw new CEFormatException("UCDecoder: High byte parity error.");
    }
    if ((p2 & 1) != np2) {
        throw new CEFormatException("UCDecoder: Low byte parity error.");
    }
    outStream.write(high_byte);
    crc.update(high_byte);
    if (l == 2) {
        outStream.write(low_byte);
        crc.update(low_byte);
    }
}
 
Example 17
Source File: BASE64Decoder.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Decode one BASE64 atom into 1, 2, or 3 bytes of data.
 */
@SuppressWarnings("fallthrough")
protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int rem)
    throws java.io.IOException
{
    int     i;
    byte    a = -1, b = -1, c = -1, d = -1;

    if (rem < 2) {
        throw new CEFormatException("BASE64Decoder: Not enough bytes for an atom.");
    }
    do {
        i = inStream.read();
        if (i == -1) {
            throw new CEStreamExhausted();
        }
    } while (i == '\n' || i == '\r');
    decode_buffer[0] = (byte) i;

    i = readFully(inStream, decode_buffer, 1, rem-1);
    if (i == -1) {
        throw new CEStreamExhausted();
    }

    if (rem > 3 && decode_buffer[3] == '=') {
        rem = 3;
    }
    if (rem > 2 && decode_buffer[2] == '=') {
        rem = 2;
    }
    switch (rem) {
    case 4:
        d = pem_convert_array[decode_buffer[3] & 0xff];
        // NOBREAK
    case 3:
        c = pem_convert_array[decode_buffer[2] & 0xff];
        // NOBREAK
    case 2:
        b = pem_convert_array[decode_buffer[1] & 0xff];
        a = pem_convert_array[decode_buffer[0] & 0xff];
        break;
    }

    switch (rem) {
    case 2:
        outStream.write( (byte)(((a << 2) & 0xfc) | ((b >>> 4) & 3)) );
        break;
    case 3:
        outStream.write( (byte) (((a << 2) & 0xfc) | ((b >>> 4) & 3)) );
        outStream.write( (byte) (((b << 4) & 0xf0) | ((c >>> 2) & 0xf)) );
        break;
    case 4:
        outStream.write( (byte) (((a << 2) & 0xfc) | ((b >>> 4) & 3)) );
        outStream.write( (byte) (((b << 4) & 0xf0) | ((c >>> 2) & 0xf)) );
        outStream.write( (byte) (((c << 6) & 0xc0) | (d  & 0x3f)) );
        break;
    }
    return;
}
 
Example 18
Source File: BASE64Decoder.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Decode one BASE64 atom into 1, 2, or 3 bytes of data.
 */
@SuppressWarnings("fallthrough")
protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int rem)
    throws java.io.IOException
{
    int     i;
    byte    a = -1, b = -1, c = -1, d = -1;

    if (rem < 2) {
        throw new CEFormatException("BASE64Decoder: Not enough bytes for an atom.");
    }
    do {
        i = inStream.read();
        if (i == -1) {
            throw new CEStreamExhausted();
        }
    } while (i == '\n' || i == '\r');
    decode_buffer[0] = (byte) i;

    i = readFully(inStream, decode_buffer, 1, rem-1);
    if (i == -1) {
        throw new CEStreamExhausted();
    }

    if (rem > 3 && decode_buffer[3] == '=') {
        rem = 3;
    }
    if (rem > 2 && decode_buffer[2] == '=') {
        rem = 2;
    }
    switch (rem) {
    case 4:
        d = pem_convert_array[decode_buffer[3] & 0xff];
        // NOBREAK
    case 3:
        c = pem_convert_array[decode_buffer[2] & 0xff];
        // NOBREAK
    case 2:
        b = pem_convert_array[decode_buffer[1] & 0xff];
        a = pem_convert_array[decode_buffer[0] & 0xff];
        break;
    }

    switch (rem) {
    case 2:
        outStream.write( (byte)(((a << 2) & 0xfc) | ((b >>> 4) & 3)) );
        break;
    case 3:
        outStream.write( (byte) (((a << 2) & 0xfc) | ((b >>> 4) & 3)) );
        outStream.write( (byte) (((b << 4) & 0xf0) | ((c >>> 2) & 0xf)) );
        break;
    case 4:
        outStream.write( (byte) (((a << 2) & 0xfc) | ((b >>> 4) & 3)) );
        outStream.write( (byte) (((b << 4) & 0xf0) | ((c >>> 2) & 0xf)) );
        outStream.write( (byte) (((c << 6) & 0xc0) | (d  & 0x3f)) );
        break;
    }
    return;
}
 
Example 19
Source File: UnicodeBOMInputStream.java    From wandora with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructs a new <code>UnicodeBOMInputStream</code> that wraps the
 * specified <code>InputStream</code>.
 * 
 * @param inputStream an <code>InputStream</code>.
 * 
 * @throws NullPointerException when <code>inputStream</code> is
 * <code>null</code>.
 * @throws IOException on reading from the specified <code>InputStream</code>
 * when trying to detect the Unicode BOM.
 */
public UnicodeBOMInputStream(final InputStream inputStream) throws  NullPointerException, IOException {
  if (inputStream == null)
    throw new NullPointerException("invalid input stream: null is not allowed");

  in = new PushbackInputStream(inputStream,4);

  final byte  bom[] = new byte[4];
  final int   read  = in.read(bom);

  switch(read) {
    case 4:
      if ((bom[0] == (byte)0xFF) &&
          (bom[1] == (byte)0xFE) &&
          (bom[2] == (byte)0x00) &&
          (bom[3] == (byte)0x00)) {
        this.bom = BOM.UTF_32_LE;
        break;
      }
      else
      if ((bom[0] == (byte)0x00) &&
          (bom[1] == (byte)0x00) &&
          (bom[2] == (byte)0xFE) &&
          (bom[3] == (byte)0xFF)) {
        this.bom = BOM.UTF_32_BE;
        break;
      }

    case 3:
      if ((bom[0] == (byte)0xEF) &&
          (bom[1] == (byte)0xBB) &&
          (bom[2] == (byte)0xBF)) {
        this.bom = BOM.UTF_8;
        break;
      }

    case 2:
      if ((bom[0] == (byte)0xFF) &&
          (bom[1] == (byte)0xFE)) {
        this.bom = BOM.UTF_16_LE;
        break;
      }
      else
      if ((bom[0] == (byte)0xFE) &&
          (bom[1] == (byte)0xFF)) {
        this.bom = BOM.UTF_16_BE;
        break;
      }

    default:
      this.bom = BOM.NONE;
      break;
  }

  if (read > 0)
    in.unread(bom,0,read);
}
 
Example 20
Source File: UCDecoder.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Decode one atom - reads the characters from the input stream, decodes
 * them, and checks for valid parity.
 */
protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int l) throws IOException {
    int i, p1, p2, np1, np2;
    byte a = -1, b = -1, c = -1;
    byte high_byte, low_byte;
    byte tmp[] = new byte[3];

    i = inStream.read(tmp);
    if (i != 3) {
            throw new CEStreamExhausted();
    }
    for (i = 0; (i < 64) && ((a == -1) || (b == -1) || (c == -1)); i++) {
        if (tmp[0] == map_array[i]) {
            a = (byte) i;
        }
        if (tmp[1] == map_array[i]) {
            b = (byte) i;
        }
        if (tmp[2] == map_array[i]) {
            c = (byte) i;
        }
    }
    high_byte = (byte) (((a & 0x38) << 2) + (b & 0x1f));
    low_byte = (byte) (((a & 0x7) << 5) + (c & 0x1f));
    p1 = 0;
    p2 = 0;
    for (i = 1; i < 256; i = i * 2) {
        if ((high_byte & i) != 0)
            p1++;
        if ((low_byte & i) != 0)
            p2++;
    }
    np1 = (b & 32) / 32;
    np2 = (c & 32) / 32;
    if ((p1 & 1) != np1) {
        throw new CEFormatException("UCDecoder: High byte parity error.");
    }
    if ((p2 & 1) != np2) {
        throw new CEFormatException("UCDecoder: Low byte parity error.");
    }
    outStream.write(high_byte);
    crc.update(high_byte);
    if (l == 2) {
        outStream.write(low_byte);
        crc.update(low_byte);
    }
}