`
uu011
  • 浏览: 29459 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
递归XML节点
   Document document = DocumentHelper.parseText(....路径..);
	   setP(document.getRootElement());

	protected void setP(Element parent){
		//List<Element> els=new ArrayList<Element>();
		if(parent.elements().size()!=0)
		{
			Iterator<Element> itel=parent.elementIterator();
			while(itel.hasNext())
			{
				Element chid=itel.next();
				chid.appendAttributes(parent);
				setP(chid);
			}			
		} 
	}
ant 取得CVS版本号
<?xml version="1.0"?>
<project name="svnNO" default="svnNO">
     <target name="svnNO">
		<echo message=" 取得SVN版本" /> 
		<exec executable="SubWCRev.exe">
		<arg value="路径" />
		<arg value="路径/svn.in" />
		<arg value="路径/svn.xml" />
			<arg value="-f" />
		</exec>      
    </target>
</project>
svn.in
<variable name="WCREV" value="$WCREV$" />
<variable name="WCDATE" value="$WCDATE$" />
java ZIP压缩
//inputFileName压缩的路径
//zipFileName压缩后的路径
public void zip(String inputFileName,String zipFileName)
{
try
{
File file=new File(inputFileName);
ZipOutputStream out=new ZipOutputStream(new FileOutputStream(zipFileName));
zip(file,out,"");
out.close();
}catch(Exception e)
{
e.printStackTrace();
}
		
}
public void zip(File file,ZipOutputStream out,String base)
{
try
{
if(file.isDirectory())
{
out.putNextEntry(new ZipEntry(base+"/"));
base=base.length()==0?"":base+"/";
File fi[]=file.listFiles();
for(int i=0;i<fi.length;i++)
{
(fi[i],out,base+fi[i].getName());
}
}else{
out.putNextEntry(new ZipEntry(base));
FileInputStream in=new FileInputStream(file);
int b;
while((b=in.read())!=-1)
{
out.write(b);
}
in.close();
}
			
		}catch(Exception e)
		{
			e.printStackTrace();
		}
	}
Global site tag (gtag.js) - Google Analytics