日期:2014-05-20 浏览次数:21021 次
public class WordCount {
public static void main(String[] args) {
InputStream is = null;
OutputStream os = null;
boolean alphaOrder = true;
if (args.length == 2 || args.length == 3) {
int i = 0;
if (args.length == 3) {
if (args[0] == null) {
// 输出错误信息
return;
}
switch (args[i++]) {
case "-a":
break;
case "-c":
alphaOrder = false;
break;
default:
// 输出错误信息
return;
}
}
if ("-".equals(args[i]))
is = System.in;
else
try {
is = new FileInputStream(args[i]);
} catch (IOException ex) {
ex.printStackTrace();
return;
}
i++;
if ("-".equals(args[i]))
os = System.out;
else
try {
os = new FileOutputStream(args[i]);
} catch (IOException ex) {
ex.printStackTrace();
return;
}
} else {
// 输出错误信息
return;
}
// 数据读写和单词计数部分自己可以写了吧
}
}