Zip « JTree « Java Swing Q&A





1. Display content of zip in JTree?    coderanch.com

3. zip to JTree    coderanch.com

I assume you know how to read all entries in a Zip file. I would keep a mapping from entry names to DefaultMutableTreeNodes. Then, when you encounter a ZipEntry, you determine its parent from the name (using the / as the separator*). You retrieve the parent node from the map, creating it if necessary. Then you create a DefaultMutableTreeNode, and add ...

4. zip to JTree    java-forums.org

Finally, I found a possible solution: public TreeNode generarArbre() { ZipFile file = null; try { file = new ZipFile(ruta); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); System.exit(1); } MutableTreeNode arrel = new DefaultMutableTreeNode(nomFitxer); Map nodes = new HashMap(); nodes.put(nomFitxer, arrel); for (Enumeration e = file.entries(); e.hasMoreElements();) { ZipEntry entry = e.nextElement(); String name = ...