Independentsoft
Any library, any programming language
Home
Purchase
Support
Company
Contact
JCompound
>
Tutorial
> List storage (folder)
The following example shows you how to get storage and list its content.
import java.io.IOException; import com.independentsoft.io.structuredstorage.CompoundFile; import com.independentsoft.io.structuredstorage.DirectoryEntry; import com.independentsoft.io.structuredstorage.Storage; import com.independentsoft.io.structuredstorage.Stream; public class Example { public static void main(String[] args) { try { CompoundFile file = new CompoundFile("c:\\temp\\test.bin"); //list root storage for (DirectoryEntry entry : file.getRoot().getDirectoryEntries()) { if (entry instanceof Stream) { System.out.println("Stream: " + entry.getName()); } else { System.out.println("Storage(Folder): " + entry.getName()); } } System.out.println("-----------------------------------------------"); //get storage and list content Storage storage = (Storage) file.getRoot().getDirectoryEntries().get("myfolder"); for (DirectoryEntry entry : storage.getDirectoryEntries()) { if (entry instanceof Stream) { System.out.println("Stream: " + entry.getName()); } else { System.out.println("Storage(Folder): " + entry.getName()); } } } catch (IOException e) { e.printStackTrace(); } } }