将一个目录下所有JAR文件自动添加到BUILD.XML文件中

import java.io.*;


public class Jar2Build {
	
	public static void main(String[] args) {
		String prefix=".\\lib\\";
		String directory="D:\\MyEclipse 6.0\\iaa_changsheng\\lib";
		printJar(prefix,directory);
	}

	private static void printJar(String prefix, String directory) {
		StringBuilder sb=new StringBuilder();
		File f=new File(directory);
		
		FilenameFilter filter=new JarFileFilter(".jar");
		String[] allJarFile=f.list(filter);
		for(String s:allJarFile)
			sb.append(prefix+s+";");
		
		System.out.println(sb.toString());
		
	}
	


}
class JarFileFilter implements FilenameFilter{
	String filter;

	public JarFileFilter(String filter) {
		super();
		this.filter = filter;
	}

	public boolean accept(File dir, String name) {
		return (name.endsWith(filter));
	}
	
	
}

 

你可能感兴趣的:(xml,MyEclipse,F#)