SVNResVersion {
public static void main{
(String[] args) throws Exception
//默认的保存路径String input =
"E://svn.xml"String outPath =
;
"E://assets.bin";
if(args !=
null&& args.length ==
2{
)
//获取传进来的路径input = args[
0outPath = args[
];
1}
];
elseSystem.
{
out.println(
"没输入路径,使用默认的路径"System.
}
);
out.println(
"资源路径"System.
+ input);
out.println(
"输出路径"+ outPath);
//最多文件的版本号 intmaxFileVersion =
0;
//记录这个文件数量 //int maxFileVersionCount = 0; intfileCount =
0HashMap
;
newHashMap
Document documet = dbBuilder.parse(input);
DocumentBuilder dbBuilder = factory.newDocumentBuilder();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//获取出根路径Element element = (Element)documet.getElementsByTagName(
"target").item(
0String mainPath = element.getAttribute(
);
"path");
//替换回游戏中使用的路径mainPath = mainPath.replaceAll(
"\\\\",
"/") +
"/";
//解析每一条svn资源的commit版本号NodeList list = documet.getElementsByTagName(
"entry"List
);
nullList
;
null;
for(
inti =
0String path = element.getAttribute(
element = (Element)list.item(i);
{
; i < list.getLength(); i++)
"path"File file =
);
newFile(path);
//过滤掉svn目录 if(path.indexOf(
".svn") != -
1System.
{
)
out.println(
"过滤掉.svn目录");
return}
;
iffileCount++;
{
(file.isFile())
//commit revisionElement versionEle = (Element)(element.getElementsByTagName(
"commit").item(
0));
if(versionEle ==
null)
continuepath = path.replaceAll(
;
"\\\\",
"/");
//替换掉前缀,保留相对路径 if(path.length() != mainPath.length()) path = path.replaceFirst(mainPath,
"");
//去掉根目录,保存文件的相对路径 intversion = Integer.parseInt( versionEle.getAttribute(
"revision") );
//System.out.println(path + ":" + version);urlList = versionMap.
get(version);
if(urlList ==
nullurlList =
{
)
newurlList.add(path);
}
versionMap.put(version, urlList);
ArrayList
(maxrlList ==
null}
maxFileVersion = version;
maxrlList = urlList;
{
)
else{
//取比较大的作为最大版本号 ifSystem.
}
}
}
}
maxFileVersion = version;
maxrlList = urlList;
{
(urlList.size() > maxrlList.size())
out.println(
"最多文件的版本号:"+ maxFileVersion +
" 数量:"System.
+ maxrlList.size());
out.println(
"处理文件数量:"+ fileCount);
//保存一份文本,用于方便查看StringBuffer stringBuffer =
newStringBuffer();
//默认版本号stringBuffer.append(maxFileVersion +
",");
//遍历所有的版本存储文件,进行版本号和文件的写入System.
out.println(
"版本号数量:"+ versionMap.size());
for(
inturlList = versionMap.
{
key : versionMap.keySet())
get(key);
ifstringBuffer.append(key +
{
(key != maxFileVersion)
"#");
//文件长度 intlength = urlList.size();
for(
inti =
0{
; i < length; i++)
//分割符stringBuffer.append(urlList.
get(i) +
"+"stringBuffer.append(
}
);
","}
}
);
//保存文本 //String url = outPath.replace(".bin", ".txt");DataOutputStream assetsOutput =
newDataOutputStream(
newassetsOutput.writeBytes(stringBuffer.toString());
FileOutputStream(outPath));
try}
assetsOutput.close();
{
catch(Exception e) {
// TODO: handle exception}
}
}
来源: http://blog.csdn.net/sujun10/article/details/78140362