/**
* 从SVN地址下载
*
* @param srcPath
* @param destPath
* @throws Exception
*/
private static File downloadFromSVN(String srcPath, String destPath)
throws Exception {
String file = srcPath.substring(srcPath.lastIndexOf("/") + 1);
String rootUrl = srcPath.substring(0, srcPath.lastIndexOf("/"));
SVNRepository repository = UtilSVN.createRepository(rootUrl);
try {
SVNNodeKind node = null;
try {
node = repository.checkPath(file, -1);
} catch (SVNException e) {
throw new Exception("SVN检测不到该文件:" + srcPath, e);
}
if (node != SVNNodeKind.FILE) {
throw new Exception(node.toString() + "不是文件");
}
SVNProperties properties = new SVNProperties();
OutputStream outputStream = null;
try {
File destFile = new File(destPath);
if (destFile.exists()) {
destFile.delete();
}
UtilIO.createFile(destFile);
outputStream = new FileOutputStream(destFile);
repository.getFile(file, -1, properties, outputStream);
outputStream.flush();
return destFile;
} catch (Exception e) {
throw new Exception("获取SVN服务器中的" + srcPath + "文件失败", e);
} finally {
if (null != outputStream) {
outputStream.close();
}
}
} finally {
UtilSVN.close(repository);
}
}