📄 input.java
字号:
import java.io.IOException;
import java.io.InputStream;
public class Input extends Filter
{
private InputStream in_;
public Input(InputStream in, Pipe output)
{
super(null, output);
in_ = in; //接通数据源
}
/* This method reads and parses a KWIC input file. The parsed data is written to the output pipe. */
protected void transform()
{
try{
boolean is_new_line = false;
boolean is_new_word = false;
boolean is_line_started = false;
int c = in_.read(); //从数据源读取数据
while(c != -1){
switch((byte) c){
case '\n':
is_new_line = true;
break;
case ' ':
is_new_word = true;
break;
case '\t':
is_new_word = true;
break;
case '\r':
break;
default:
if(is_new_line)
{
output_.write('\n');
is_new_line = false;
is_line_started = false;
}
if(is_new_word)
{
if(is_line_started)
output_.write(' ');
is_new_word = false;
}
output_.write(c); //写到"output"中
is_line_started = true;
break;
}
c = in_.read();
}
output_.write('\n');
output_.closeWriter();
}catch(IOException exc){
exc.printStackTrace();
System.err.println("KWIC Error: Could not read the input file.");
System.exit(1);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -