Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3804EC083 for ; Sun, 3 Nov 2013 18:24:01 +0000 (UTC) Received: (qmail 81417 invoked by uid 500); 3 Nov 2013 18:23:59 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 81327 invoked by uid 500); 3 Nov 2013 18:23:59 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 81319 invoked by uid 99); 3 Nov 2013 18:23:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Nov 2013 18:23:58 +0000 X-ASF-Spam-Status: No, hits=2.3 required=5.0 tests=SPF_SOFTFAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: softfail (nike.apache.org: transitioning domain of yogeshronly4u@gmail.com does not designate 216.139.250.139 as permitted sender) Received: from [216.139.250.139] (HELO joe.nabble.com) (216.139.250.139) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Nov 2013 18:23:53 +0000 Received: from [192.168.236.139] (helo=joe.nabble.com) by joe.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1Vd2Ch-0006Ie-2J for user@commons.apache.org; Sun, 03 Nov 2013 10:15:15 -0800 Date: Sun, 3 Nov 2013 10:15:00 -0800 (PST) From: yogeshrai To: user@commons.apache.org Message-ID: <1383502500050-4656326.post@n4.nabble.com> In-Reply-To: <87wqkpu6w3.fsf@v35516.1blu.de> References: <1383413968928-4656283.post@n4.nabble.com> <871u2xvm3f.fsf@v35516.1blu.de> <87wqkpu6w3.fsf@v35516.1blu.de> Subject: Re: [compress] not able to set extra field ExtendedTimestamp using commons.compress.archivers.zip MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Thnx a lot Stefan for prompt reply.I did made necessary change as suggested by u.Still even when i set all 3 date types to old date and then try to extract via default archive manager , m stuck with current date time for individual files bundled in. M i missing anything more here.M using ubuntu 12.0X as test machine here.common compress 1.6 jar in use. Here's update test class. class EOSUnixSystemCall { public static void main (String args[]) { EOSUnixSystemCall.compressFolder("/home/yogeshrai/testdir", "/home/yogeshrai/testdir/testzip"); } public static void compressFolder(String sourceFolder, String absoluteZipfilepath) { try { File srcFolder = new File(sourceFolder); if(srcFolder != null && srcFolder.isDirectory()) { Iterator i = FileUtils.iterateFiles(srcFolder,null, true); File zipFile = new File(absoluteZipfilepath); zipFile.createNewFile(); OutputStream outputStream = new FileOutputStream(zipFile); ArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(outputStream); int srcFolderLength = srcFolder.getAbsolutePath().length() + 1; // +1 to remove the last file separator while(i.hasNext()) { File file = i.next(); String relativePath = file.getAbsolutePath().substring(srcFolderLength); ZipArchiveEntry zipArchiveEntry = new ZipArchiveEntry(relativePath); //add extended timestamp extra field for zip archive entry Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.set(Calendar.YEAR, 1998); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DATE, 1); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.MILLISECOND, 0); Date timeMillis = cal.getTime(); X5455_ExtendedTimestamp xf = new X5455_ExtendedTimestamp(); xf.setModifyJavaTime(timeMillis); xf.setCreateJavaTime(timeMillis); xf.setAccessJavaTime(timeMillis); xf.setFlags((byte) 4); zipArchiveEntry.addExtraField(xf); zipOutputStream.putArchiveEntry(zipArchiveEntry); FileInputStream fis = null; try { fis = new FileInputStream(file); IOUtils.copy(fis , zipOutputStream); }finally { fis.close(); zipOutputStream.closeArchiveEntry(); } } zipOutputStream.finish(); zipOutputStream.close(); outputStream.close(); } }catch (Exception e) { e.printStackTrace(); } } } -- View this message in context: http://apache-commons.680414.n4.nabble.com/not-able-to-set-extra-field-ExtendedTimestamp-using-commons-compress-archivers-zip-tp4656283p4656326.html Sent from the Commons - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org