filefilter.java
来自「设计模式是软件工程的核心思想」· Java 代码 · 共 40 行
JAVA
40 行
import java.io.*;
public class FileFilter extends FilterInputStream {
static int MAX=1000;
public FileFilter(InputStream f) {
super(f);
}
//------------------------
public String readLine() {
String s;
int length = 0;
byte b[] = new byte[MAX];
try {
length = super.read(b);
s = new String(b, 0, length);
} catch (IOException e) {
s = "";
}
StringBuffer buf = new StringBuffer(s);
boolean punctFound = true;
for (int i=0; i < length; i++) {
char ch = buf.charAt (i);
if (punctFound && (ch != ' ') ) {
ch = Character.toUpperCase (ch);
buf.setCharAt (i, ch);
punctFound = false;
}
if (ch == '.')
punctFound = true;
}
s = buf.toString ();
return s;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?