📄 xreaderinputstream.java
字号:
/****************************************************************
* XBrowser - eXtended web Browser *
* *
* Copyright (c) 2000-2001 Armond Avanes *
* Refer to ReadMe & License files for more information *
* *
* *
* By: Brian Harrington *
* brh0001@unt.edu *
* http://xbrowser.sourceforge.net/ *
*****************************************************************/
package xbrowser.renderer.custom;
import java.io.*;
import sun.io.*;
/**
* This class acts as a bridge to convert from a reader object
* to an input stream. It is the exact opposite of the input
* stream reader class in the jdk.
*
* @author Brian Harrington
* @version 1.0
**/
public class XReaderInputStream extends InputStream
{
/**
* Create a new reader input stream.
**/
public XReaderInputStream(Reader in)
{
this.in=in;
cbuffer=new char[1024];
bbuffer=new byte[4096];
ctb=CharToByteConverter.getDefault();
length=0;
read=0;
}
/**
* Read one byte from reader.
**/
public int read() throws IOException
{
// Check if need to get more
if(length-read==0)
{
length=in.read(cbuffer);
if(length==-1)
return -1;
length=ctb.convertAny(cbuffer, 0, length, bbuffer, 0, bbuffer.length);
read=0;
}
// Get one byte
return bbuffer[read++];
}
// Attributes:
protected Reader in; // Reader object
// Buffer for characters
protected char[] cbuffer;
protected byte[] bbuffer;
protected int length;
protected int read;
protected CharToByteConverter ctb; // Char to byte converter
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -