Demo.java revision 4123
3909N/A * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. 0N/A * Redistribution and use in source and binary forms, with or without 0N/A * modification, are permitted provided that the following conditions 0N/A * - Redistributions of source code must retain the above copyright 2362N/A * notice, this list of conditions and the following disclaimer. 0N/A * - Redistributions in binary form must reproduce the above copyright 0N/A * notice, this list of conditions and the following disclaimer in the 0N/A * documentation and/or other materials provided with the distribution. 0N/A * - Neither the name of Oracle nor the names of its 0N/A * contributors may be used to endorse or promote products derived 0N/A * from this software without specific prior written permission. 0N/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 0N/A * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 2362N/A * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2362N/A * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 2362N/A * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0N/A * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 0N/A * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 0N/A * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 0N/A * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 0N/A * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 0N/A * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0N/A * ZipFileSystem usage demo 0N/A * java Demo action ZipfileName [...] 0N/A * @author Xueming Shen 0N/A rename,
// <java Demo rename zipfile src dst> 0N/A // rename entry src to dst inside zipfile 0N/A movein,
// <java Demo movein zipfile src dst> 3724N/A // move an external src file into zipfile 3724N/A // move a zipfile entry src out to dst 3724N/A // copy entry src to dst inside zipfile 0N/A copyin,
// <java Demo copyin zipfile src dst> 0N/A // copy an external src file into zipfile 0N/A // copy an external src file into zipfile 0N/A // as entry dst, with attributes (timestamp) 0N/A // copy zipfile entry src" out to file dst 0N/A zzmove,
// <java Demo zzmove zfsrc zfdst path> 0N/A zzcopy,
// <java Demo zzcopy zfsrc zfdst path> 0N/A // copy path from zipfile zfsrc to zipfile 0N/A attrs,
// <java Demo attrs zipfile path> 0N/A // printout the attributes of entry path 0N/A // printout the storespace attrs of entry path 0N/A // set the lastModifiedTime of entry path 0N/A list,
// <java Demo list zipfile [dir]> 0N/A // recursively list all entries of dir 0N/A // via DirectoryStream 0N/A tlist,
// <java Demo tlist zipfile [dir]> 0N/A // list with buildDirTree=true 0N/A vlist,
// <java Demo vlist zipfile [dir]> 0N/A // recursively verbose list all entries of 0N/A // dir via DirectoryStream 0N/A walk,
// <java Demo walk zipfile [dir]> 0N/A // recursively walk all entries of dir 0N/A // via Files.walkFileTree 0N/A twalk,
// <java Demo twalk zipfile [dir]> 0N/A // walk with buildDirTree=true 0N/A extract,
// <java Demo extract zipfile file [...]> 0N/A update,
// <java Demo extract zipfile file [...]> 0N/A delete,
// <java Demo delete zipfile file [...]> 0N/A add,
// <java Demo add zipfile file [...]> 0N/A create,
// <java Demo create zipfile file [...]> 0N/A // create a new zipfile if it doesn't exit 0N/A // and then add the file(s) into it. 0N/A attrs2,
// <java Demo attrs2 zipfile file [...]> 0N/A // test different ways to print attrs 0N/A //list(fs.getPath("/"), true); 0N/A * Not used in demo, but included for demonstrational purposes. 0N/A * Not used in demo, but included for demonstrational purposes. //System.out.println("copying..." + path); * Not used in demo, but included for demonstrational purposes. * Checks that the content of two paths are equal. * Not used in demo, but included for demonstrational purposes. //System.out.printf("checking <%s> vs <%s>...%n", // src.toString(), dst.toString()); byte[]
bufSrc =
new byte[
8192];
byte[]
bufDst =
new byte[
8192];
byte[]
buf =
new byte[
8192];