风动还是旗动?仁者心动。
文字只不过是指月的手指,而不是月亮本身,能透过指月的手指看到月亮本身才是文字的目的所在。
ant学习-扩展编程
上一篇 /
下一篇 2007-01-23 17:17:39
/ 个人分类:ant学习
ODh,s0r
F*Iz.Y01、新建的类必须是Task的扩展51Testing软件测试网Q4U Of!J(Q*y
[;H
51Testing软件测试网+qDM-|KxW2、类中必须重写execute()方法
4l*ZAM+_5d
H0V0PR+J@
n0Rw"K/P.uR0下面是一个对文件排序的扩展任务类51Testing软件测试网/nI!cn$k^9o
^%ep(gs De.N8_A0import org.apache.tools.ant.BuildException;51Testing软件测试网X;y}
gz
import org.apache.tools.ant.Task;51Testing软件测试网kV0p9J}Vu
import java.io.*;51Testing软件测试网t-N8F&Ff"ic?9US
import java.util.*;
ABT'iJYa8i0]
NR,r`0/**
M0mjYH0JK0 *
.Wz!Ems.~ CGTN0 * @author xugang51Testing软件测试网)it(D,}?2~w
* A simple example task to srot a file51Testing软件测试网_SlitQVT
n
*
+Fg2}4D|hu2Vv^0 */
r~/W7GKxf8|051Testing软件测试网5PZ
C@
r"K$npublic class FileSorter extends Task {
bV
T5?"GSuBz
b0 private File file, toFile;51Testing软件测试网%h4P_2`#e1x2b
51Testing软件测试网+I|0r5R&xH@d"zx-}
//The method excuting the task
9Uv/e;|W[aWk0 public void execute() throws BuildException{51Testing软件测试网'W6o\Sx[I:AV:F
System.out.println("Sorting file=" +file);51Testing软件测试网
U z;a D$N
try{
6|"Nm-y(Z0 BufferedReader from =
gu.k6]*S5h/KB7WC g0 new BufferedReader(new FileReader(file));
V(PR2|8]3d0 BufferedWriter to =51Testing软件测试网&}W!l)d5AP
new BufferedWriter(new FileWriter(toFile));51Testing软件测试网7?*\bwm/x}:gn cJ!iq
List allLines = new ArrayList();
,Od"pK%s0 51Testing软件测试网5j}~ ~ k3_'vA
//read in the input file51Testing软件测试网G6];o/gf
String line = from.readLine();
PkRuo.F~
Y0 while (line != null)
x'YnZ mgn9eCY0 {
xh7k6?+wa0 allLines.add(line);
*A!]u?uy'g/_0 line = from.readLine();
Z8P#FcB)yky Y0 }
m
SwS&UB|s0 from.close();51Testing软件测试网7h"@d_Yg!g(D.O
{