类java.io.PushbackInputStream源码实例Demo

下面列出了怎么用java.io.PushbackInputStream的API类实例代码及写法,或者点击链接到github查看源代码。

public EmptyBodyCheckingHttpInputMessage(HttpInputMessage inputMessage) throws IOException {
	this.headers = inputMessage.getHeaders();
	InputStream inputStream = inputMessage.getBody();
	if (inputStream.markSupported()) {
		inputStream.mark(1);
		this.body = (inputStream.read() != -1 ? inputStream : null);
		inputStream.reset();
	}
	else {
		PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
		int b = pushbackInputStream.read();
		if (b == -1) {
			this.body = null;
		}
		else {
			this.body = pushbackInputStream;
			pushbackInputStream.unread(b);
		}
	}
}
 
源代码2 项目: j2ssh-maverick   文件: ServerAuthenticatorNone.java
/**
 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{

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

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

  return new ServerAuthenticatorNone(in,out);
}
 
源代码3 项目: nutch-htmlunit   文件: HttpResponse.java
private int parseStatusLine(PushbackInputStream in, StringBuffer line)
  throws IOException, HttpException {
  readLine(in, line, false);

  int codeStart = line.indexOf(" ");
  int codeEnd = line.indexOf(" ", codeStart+1);

  // handle lines with no plaintext result code, ie:
  // "HTTP/1.1 200" vs "HTTP/1.1 200 OK"
  if (codeEnd == -1) 
    codeEnd= line.length();

  int code;
  try {
    code= Integer.parseInt(line.substring(codeStart+1, codeEnd));
  } catch (NumberFormatException e) {
    throw new HttpException("bad status line '" + line 
                            + "': " + e.getMessage(), e);
  }

  return code;
}
 
源代码4 项目: openjdk-8-source   文件: UUDecoder.java
/**
 * 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));
    }
}
 
源代码5 项目: spork   文件: Utf8StorageConverter.java
private Object consumeComplexType(PushbackInputStream in, ResourceFieldSchema complexFieldSchema) throws IOException {
    Object field;
    switch (complexFieldSchema.getType()) {
    case DataType.BAG:
        field = consumeBag(in, complexFieldSchema);
        break;
    case DataType.TUPLE:
        field = consumeTuple(in, complexFieldSchema);
        break;
    case DataType.MAP:
        field = consumeMap(in, complexFieldSchema);
        break;
    default:
        throw new IOException("Unknown complex data type");
    }
    return field;
}
 
源代码6 项目: dragonwell8_jdk   文件: UUDecoder.java
/**
 * 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));
    }
}
 
源代码7 项目: nutch-selenium   文件: HttpResponse.java
private int parseStatusLine(PushbackInputStream in, StringBuffer line) throws IOException, HttpException {
    readLine(in, line, false);

    int codeStart = line.indexOf(" ");
    int codeEnd = line.indexOf(" ", codeStart + 1);

    // handle lines with no plaintext result code, ie:
    // "HTTP/1.1 200" vs "HTTP/1.1 200 OK"
    if (codeEnd == -1)
        codeEnd = line.length();

    int code;
    try {
        code = Integer.parseInt(line.substring(codeStart + 1, codeEnd));
    } catch (NumberFormatException e) {
        throw new HttpException("bad status line '" + line + "': " + e.getMessage(), e);
    }

    return code;
}
 
源代码8 项目: gcs   文件: CMapParser.java
private void parseBegincidchar(Number cosCount, PushbackInputStream cmapStream, CMap result) throws IOException
{
    for (int j = 0; j < cosCount.intValue(); j++)
    {
        Object nextToken = parseNextToken(cmapStream);
        if (nextToken instanceof Operator)
        {
            if (!((Operator) nextToken).op.equals("endcidchar"))
            {
                throw new IOException("Error : ~cidchar contains an unexpected operator : "
                        + ((Operator) nextToken).op);
            }
            break;
        }
        byte[] inputCode = (byte[]) nextToken;
        int mappedCode = (Integer) parseNextToken(cmapStream);
        int mappedCID = createIntFromBytes(inputCode);
        result.addCIDMapping(mappedCode, mappedCID);
    }
}
 
源代码9 项目: openjdk-jdk8u   文件: UUDecoder.java
/**
 * 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;
        }
    }
}
 
源代码10 项目: netty-4.1.22   文件: ChunkedStream.java
/**
 * Creates a new instance that fetches data from the specified stream.创建一个新实例,该实例从指定的流中获取数据。
 *
 * @param chunkSize the number of bytes to fetch on each
 *                  {@link #readChunk(ChannelHandlerContext)} call
 */
public ChunkedStream(InputStream in, int chunkSize) {
    if (in == null) {
        throw new NullPointerException("in");
    }
    if (chunkSize <= 0) {
        throw new IllegalArgumentException(
                "chunkSize: " + chunkSize +
                " (expected: a positive integer)");
    }

    if (in instanceof PushbackInputStream) {
        this.in = (PushbackInputStream) in;
    } else {
        this.in = new PushbackInputStream(in);
    }
    this.chunkSize = chunkSize;
}
 
源代码11 项目: PdfBox-Android   文件: CMapParser.java
private void parseBegincodespacerange(Object previousToken, PushbackInputStream cmapStream, CMap result) throws IOException
{
    Number cosCount = (Number) previousToken;
    for (int j = 0; j < cosCount.intValue(); j++)
    {
        Object nextToken = parseNextToken(cmapStream);
        if (nextToken instanceof Operator)
        {
            if (!((Operator) nextToken).op.equals("endcodespacerange"))
            {
                throw new IOException("Error : ~codespacerange contains an unexpected operator : "
                        + ((Operator) nextToken).op);
            }
            break;
        }
        byte[] startRange = (byte[]) nextToken;
        byte[] endRange = (byte[]) parseNextToken(cmapStream);
        CodespaceRange range = new CodespaceRange();
        range.setStart(startRange);
        range.setEnd(endRange);
        result.addCodespaceRange(range);
    }
}
 
源代码12 项目: james-project   文件: CachedBlobStore.java
static RequireStream eager() {
    return in -> length -> {
        //+1 is to evaluate hasMore
        var stream = new PushbackInputStream(in, length + 1);
        var bytes = new byte[length];
        int readByteCount = IOUtils.read(stream, bytes);
        Optional<byte[]> firstBytes;
        boolean hasMore;
        if (readByteCount < 0) {
            firstBytes = Optional.empty();
            hasMore = false;
        } else {
            byte[] readBytes = Arrays.copyOf(bytes, readByteCount);
            hasMore = hasMore(stream);
            stream.unread(readBytes);
            firstBytes = Optional.of(readBytes);
        }
        return new ReadAheadInputStream(stream, firstBytes, hasMore);
    };
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: UUDecoder.java
/**
 * 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;
        }
    }
}
 
源代码14 项目: netbeans   文件: DefaultAttributes.java
/** Tests whether InputStream contains serialized data
* @param pbStream is pushback input stream; tests 4 bytes and then returns them back
* @return true if the file has serialized form
*/
static private final boolean isSerialized(PushbackInputStream pbStream)
throws IOException {
    int[] serialPattern = { '\u00AC', '\u00ED', '\u0000', '\u0005' }; //NOI18N patern for serialized objects
    byte[] checkedArray = new byte[serialPattern.length];
    int unsignedConv = 0;

    pbStream.read(checkedArray, 0, checkedArray.length);
    pbStream.unread(checkedArray);

    for (int i = 0; i < checkedArray.length; i++) {
        unsignedConv = (checkedArray[i] < 0) ? (checkedArray[i] + 256) : checkedArray[i];

        if (serialPattern[i] != unsignedConv) {
            return false;
        }
    }

    return true;
}
 
源代码15 项目: jdk8u_jdk   文件: UUDecoder.java
/**
 * 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));
    }
}
 
源代码16 项目: jdk8u_jdk   文件: UUDecoder.java
/**
 * 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;
        }
    }
}
 
源代码17 项目: wisdom   文件: AsyncInputStream.java
/**
 * Creates an instance of {@link org.wisdom.framework.vertx.AsyncInputStream}.
 *
 * @param vertx     the Vert.X instance
 * @param executor  the executor used to read the chunk
 * @param in        the input stream to read
 * @param chunkSize the chunk size
 */
public AsyncInputStream(Vertx vertx, ExecutorService executor, InputStream in, int chunkSize) {
    if (in == null) {
        throw new NullPointerException("in");
    }
    if (vertx == null) {
        throw new NullPointerException("vertx");
    }
    this.vertx = vertx;
    if (chunkSize <= 0) {
        throw new IllegalArgumentException(
                "chunkSize: " + chunkSize +
                        " (expected: a positive integer)");
    }

    if (in instanceof PushbackInputStream) {
        this.in = (PushbackInputStream) in;
    } else {
        this.in = new PushbackInputStream(in);
    }
    this.chunkSize = chunkSize;
    this.executor = executor;
}
 
public EmptyBodyCheckingHttpInputMessage(HttpInputMessage inputMessage) throws IOException {
	this.headers = inputMessage.getHeaders();
	InputStream inputStream = inputMessage.getBody();
	if (inputStream == null) {
		this.body = null;
	}
	else if (inputStream.markSupported()) {
		inputStream.mark(1);
		this.body = (inputStream.read() != -1 ? inputStream : null);
		inputStream.reset();
	}
	else {
		PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
		int b = pushbackInputStream.read();
		if (b == -1) {
			this.body = null;
		}
		else {
			this.body = pushbackInputStream;
			pushbackInputStream.unread(b);
		}
	}
	this.method = ((HttpRequest) inputMessage).getMethod();
}
 
源代码19 项目: hottub   文件: CharacterDecoder.java
/**
 * Decode the text from the InputStream and write the decoded
 * octets to the OutputStream. This method runs until the stream
 * is exhausted.
 * @exception CEFormatException An error has occurred while decoding
 * @exception CEStreamExhausted The input stream is unexpectedly out of data
 */
public void decodeBuffer(InputStream aStream, OutputStream bStream) throws IOException {
    int     i;
    int     totalBytes = 0;

    PushbackInputStream ps = new PushbackInputStream (aStream);
    decodeBufferPrefix(ps, bStream);
    while (true) {
        int length;

        try {
            length = decodeLinePrefix(ps, bStream);
            for (i = 0; (i+bytesPerAtom()) < length; i += bytesPerAtom()) {
                decodeAtom(ps, bStream, bytesPerAtom());
                totalBytes += bytesPerAtom();
            }
            if ((i + bytesPerAtom()) == length) {
                decodeAtom(ps, bStream, bytesPerAtom());
                totalBytes += bytesPerAtom();
            } else {
                decodeAtom(ps, bStream, length - i);
                totalBytes += (length - i);
            }
            decodeLineSuffix(ps, bStream);
        } catch (CEStreamExhausted e) {
            break;
        }
    }
    decodeBufferSuffix(ps, bStream);
}
 
源代码20 项目: openjdk-8   文件: UCDecoder.java
/**
 * 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);
}
 
源代码21 项目: uavstack   文件: CharacterDecoderUrl.java
public void decodeBuffer(InputStream inputstream, OutputStream outputstream) throws IOException {

        @SuppressWarnings("unused")
        int j = 0;
        PushbackInputStream pushbackinputstream = new PushbackInputStream(inputstream);
        decodeBufferPrefix(pushbackinputstream, outputstream);
        try {
            do {
                int k = decodeLinePrefix(pushbackinputstream, outputstream);
                int i;
                for (i = 0; i + bytesPerAtom() < k; i += bytesPerAtom()) {
                    decodeAtom(pushbackinputstream, outputstream, bytesPerAtom());
                    j += bytesPerAtom();
                }

                if (i + bytesPerAtom() == k) {
                    decodeAtom(pushbackinputstream, outputstream, bytesPerAtom());
                    j += bytesPerAtom();
                }
                else {
                    decodeAtom(pushbackinputstream, outputstream, k - i);
                    j += k - i;
                }
                decodeLineSuffix(pushbackinputstream, outputstream);
            }
            while (true);
        }
        catch (IOException cestreamexhausted) {
            decodeBufferSuffix(pushbackinputstream, outputstream);
        }
    }
 
源代码22 项目: jdk8u_jdk   文件: UCDecoder.java
/**
 * 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);
}
 
源代码23 项目: gcs   文件: CMapParser.java
private void parseBeginbfchar(Number cosCount, PushbackInputStream cmapStream, CMap result) throws IOException
{
    for (int j = 0; j < cosCount.intValue(); j++)
    {
        Object nextToken = parseNextToken(cmapStream);
        if (nextToken instanceof Operator)
        {
            if (!((Operator) nextToken).op.equals("endbfchar"))
            {
                throw new IOException("Error : ~bfchar contains an unexpected operator : "
                        + ((Operator) nextToken).op);
            }
            break;
        }
        byte[] inputCode = (byte[]) nextToken;
        nextToken = parseNextToken(cmapStream);
        if (nextToken instanceof byte[])
        {
            byte[] bytes = (byte[]) nextToken;
            String value = createStringFromBytes(bytes);
            result.addCharMapping(inputCode, value);
        }
        else if (nextToken instanceof LiteralName)
        {
            result.addCharMapping(inputCode, ((LiteralName) nextToken).name);
        }
        else
        {
            throw new IOException("Error parsing CMap beginbfchar, expected{COSString "
                    + "or COSName} and not " + nextToken);
        }
    }
}
 
源代码24 项目: cxf   文件: AsyncHTTPConduit.java
protected InputStream getPartialResponse() throws IOException {
    InputStream in = null;
    int responseCode = getResponseCode();
    if (responseCode == HttpURLConnection.HTTP_ACCEPTED
        || responseCode == HttpURLConnection.HTTP_OK) {

        Header head = httpResponse.getFirstHeader(HttpHeaderHelper.CONTENT_LENGTH);
        int cli = 0;
        if (head != null) {
            cli = Integer.parseInt(head.getValue());
        }
        head = httpResponse.getFirstHeader(HttpHeaderHelper.TRANSFER_ENCODING);
        boolean isChunked = head != null &&  HttpHeaderHelper.CHUNKED.equalsIgnoreCase(head.getValue());
        head = httpResponse.getFirstHeader(HttpHeaderHelper.CONNECTION);
        boolean isEofTerminated = head != null &&  HttpHeaderHelper.CLOSE.equalsIgnoreCase(head.getValue());
        if (cli > 0) {
            in = getInputStream();
        } else if (isChunked || isEofTerminated) {
            // ensure chunked or EOF-terminated response is non-empty
            try {
                PushbackInputStream pin =
                    new PushbackInputStream(getInputStream());
                int c = pin.read();
                if (c != -1) {
                    pin.unread((byte)c);
                    in = pin;
                }
            } catch (IOException ioe) {
                // ignore
            }
        }
    }
    return in;
}
 
源代码25 项目: dragonwell8_jdk   文件: UCDecoder.java
/**
 * 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);
}
 
源代码26 项目: gpx-animator   文件: GpxParser.java
@SuppressWarnings("PMD.CloseResource") // The returned stream will be used and closed in a try-with-resources block
public static InputStream decompressStream(final InputStream input) throws IOException {
    final PushbackInputStream pb = new PushbackInputStream(input, 2);
    final byte[] signature = new byte[2];
    final int numBytesRead = pb.read(signature);
    pb.unread(signature, 0, numBytesRead);
    return signature[0] == (byte) 0x1f && signature[1] == (byte) 0x8b ? new GZIPInputStream(pb) : pb;
}
 
源代码27 项目: itext2   文件: RtfCtrlWordMgr.java
/**
	 * Constructor
	 * @param rtfParser The parser object this manager works with.
	 * @param reader the PushbackReader from the tokeniser.
	 */
	public RtfCtrlWordMgr(RtfParser rtfParser, PushbackInputStream reader) {
		ctrlWordMap = new RtfCtrlWordMap(rtfParser);
		
//		// TIMING DEBUG INFO
//		endFree = Runtime.getRuntime().freeMemory();
//		endTime = System.currentTimeMillis();
//		endDate = new Date();
//		System.out.println("RtfCtrlWordMgr start date: " + startDate.toLocaleString());
//		System.out.println("RtfCtrlWordMgr end date  : " + endDate.toLocaleString());
//		System.out.println("  Elapsed time    : " + Long.toString(endTime - startTime) + " milliseconds.");
//		System.out.println("Begin Constructor RtfCtrlWordMgr , free mem is " + df.format(startFree / 1024) + "k");
//		System.out.println("End Constructor RtfCtrlWordMgr , free mem is " + df.format(endFree / 1024) + "k");
//        System.out.println("RtfCtrlWordMgr used approximately " + df.format((startFree - endFree) / 1024) + "k");
	}
 
源代码28 项目: dragonwell8_jdk   文件: UUDecoder.java
/**
 * 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.");
    }
}
 
源代码29 项目: jdk8u_jdk   文件: CharacterDecoder.java
/**
 * Decode the text from the InputStream and write the decoded
 * octets to the OutputStream. This method runs until the stream
 * is exhausted.
 * @exception CEFormatException An error has occurred while decoding
 * @exception CEStreamExhausted The input stream is unexpectedly out of data
 */
public void decodeBuffer(InputStream aStream, OutputStream bStream) throws IOException {
    int     i;
    int     totalBytes = 0;

    PushbackInputStream ps = new PushbackInputStream (aStream);
    decodeBufferPrefix(ps, bStream);
    while (true) {
        int length;

        try {
            length = decodeLinePrefix(ps, bStream);
            for (i = 0; (i+bytesPerAtom()) < length; i += bytesPerAtom()) {
                decodeAtom(ps, bStream, bytesPerAtom());
                totalBytes += bytesPerAtom();
            }
            if ((i + bytesPerAtom()) == length) {
                decodeAtom(ps, bStream, bytesPerAtom());
                totalBytes += bytesPerAtom();
            } else {
                decodeAtom(ps, bStream, length - i);
                totalBytes += (length - i);
            }
            decodeLineSuffix(ps, bStream);
        } catch (CEStreamExhausted e) {
            break;
        }
    }
    decodeBufferSuffix(ps, bStream);
}
 
源代码30 项目: TencentKona-8   文件: UCDecoder.java
/**
 * 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);
}
 
 类所在包
 同包方法