public void listDirectoryNode(SVNRepository repository, String dirUrl, FileNode node) { String currentPath = ""; List list = new ArrayList(); Collection root; try { String finalPath[] = dirUrl.split("/"); for (int i = 5; i < finalPath.length; i++) { currentPath += finalPath[i] + "/"; } root = repository.getDir(currentPath, -1, null, (Collection) null); Iterator iterator = root.iterator(); while (iterator.hasNext()) { SVNDirEntry entry = (SVNDirEntry) iterator.next(); if (entry.getKind() == SVNNodeKind.DIR) { FileNode subDirNode = new FileNode(entry.getName(), entry .getURL().toDecodedString(), entry.getRevision(), entry.getAuthor(), entry.getSize(), entry.getDate(), null, entry.getKind()); listDirectoryNode(repository, entry.getURL().toDecodedString(), subDirNode); list.add(subDirNode); } } } catch (SVNException e) { // TODO Auto-generated catch block e.printStackTrace(); } node.setChildren(list); }
在entry.getURL().toString();的时候,当地址是以http://开头的话会出现乱码。原因是http的安全地址机制,这样写的话就没有问题了:entry.getURL().toDecodedString();