Dear Wiki user, You have subscribed to a wiki page or wiki category on "Commons Wiki" for change notification.
The following page has been changed by KenTanaka: http://wiki.apache.org/jakarta-commons/ExtractAndDecompressGzipFiles The comment on the change is: Described the ideas behind constructing the name argument for resolveFile method ------------------------------------------------------------------------------ }}} The contents of the {{{content.txt}}} and {{{non-gzip.txt}}} files are just a directory listings, dump in anything you want here. For this example the sample {{{archive.tar}}} is located in the {{{/extra/data/tryVfs}}} directory. You can see that hardcoded in the java example below. The {{{content.txt}}} and {{{non-gzip.txt}}} files will be extracted into the same location. + + = Key Concept = + An essential ingredient for this "recipe" is the '''name''' argument for the {{{FileSystemManager.resolveFile(String name)}}} method. This is present around lines 99-100 in the ExtractFromGzipInTar.java code listing below. The important work of connecting to the content.txt file inside the content.txt.gz file inside the archive.tar file is performed by + {{{ + FileSystemManager fsManager = VFS.getManager(); + FileObject file = fsManager.resolveFile( "gz:tar:file:///extra/data/tryVfs/archive.tar!/tardir/content.txt.gz!content.txt" ); + }}} + In order to build similar strings for your own purposes, you will need to understand what is going on here. The paths to the file of interest are chained together with the "!" character as a separator. At the same time the corresponding file system scheme designators ("file:", "tar:" and "gz:") should be prepended onto the front in reverse order. Taking this one step at a time, we have the full path to the `archive.tar` file (__/extra/data/tryVfs/archive.tar__), which is accessed through the normal file system '''file:''' + + '''file:'''__///extra/data/tryVfs/archive.tar__ + + Now we will treat the file as a '''tar:''' file and inside this archive we will append a "''!''" and navigate to __`/tardir/content.txt.gz`__. + + '''tar:'''`file:///extra/data/tryVfs/archive.tar`''!''__`/tardir/content.txt.gz`__ + + Finally we will use the '''gz:''' file system to read the uncompressed __`content.txt`__ (again using the "''!''" separator character) + + '''gz:'''`tar:file:///extra/data/tryVfs/archive.tar!/tardir/content.txt.gz`''!''__`content.txt`__ + + + = pom.xml Project file = This example uses Maven2. There is a '''{{{pom.xml}}}''' to define the project --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
