Java Code Examples for java.util.jar.JarEntry#getCrc()
The following examples show how to use
java.util.jar.JarEntry#getCrc() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestNormal.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 2
Source File: TestNormal.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 3
Source File: TestNormal.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 4
Source File: TestNormal.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 5
Source File: TestNormal.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 6
Source File: TestNormal.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 7
Source File: TestNormal.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 8
Source File: TestNormal.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 9
Source File: TestNormal.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 10
Source File: TestNormal.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 11
Source File: TestNormal.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 12
Source File: JarDiff.java From webstart with MIT License | 6 votes |
public boolean contains( JarFile2 f, JarEntry e ) throws IOException { JarEntry thisEntry = getEntryByName( e.getName() ); // Look up name in 'this' Jar2File - if not exist return false if ( thisEntry == null ) { return false; } // Check CRC - if no match - return false if ( thisEntry.getCrc() != e.getCrc() ) { return false; } // Check contents - if no match - return false InputStream oldIS = getJarFile().getInputStream( thisEntry ); InputStream newIS = f.getJarFile().getInputStream( e ); boolean retValue = differs( oldIS, newIS ); return !retValue; }
Example 13
Source File: TestNormal.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { try { if (jf1.size() != jf2.size()) { throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() + " have different number of entries"); } for (JarEntry elem1 : Collections.list(jf1.entries())) { JarEntry elem2 = jf2.getJarEntry(elem1.getName()); if (elem2 == null) { throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); } if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { throw new Exception("The crc of " + elem1.getName() + " is different."); } } } finally { jf1.close(); jf2.close(); } }
Example 14
Source File: JarDiff.java From webstart with MIT License | 5 votes |
public String hasSameContent( JarFile2 file, JarEntry entry ) throws IOException { String thisName = null; Long crcL = entry.getCrc(); // check if this jar contains files with the passed in entry's crc if ( _crcToEntryMap.containsKey( crcL ) ) { // get the Linked List with files with the crc LinkedList ll = (LinkedList) _crcToEntryMap.get( crcL ); // go through the list and check for content match ListIterator li = ll.listIterator( 0 ); while ( li.hasNext() ) { JarEntry thisEntry = (JarEntry) li.next(); // check for content match InputStream oldIS = getJarFile().getInputStream( thisEntry ); InputStream newIS = file.getJarFile().getInputStream( entry ); if ( !differs( oldIS, newIS ) ) { thisName = thisEntry.getName(); return thisName; } } } return thisName; }
Example 15
Source File: ExamineArchiveTask.java From portals-pluto with Apache License 2.0 | 5 votes |
public void execute() throws BuildException { try { JarInputStream jarIn = new JarInputStream( new FileInputStream( archive ) ); JarEntry entry; while ( ( entry = jarIn.getNextJarEntry() ) != null ) { String name = entry.getName(); long crc = entry.getCrc(); long size = entry.getSize(); long compressedSize = entry.getCompressedSize(); int compressMethod = entry.getMethod(); long timeStamp = entry.getTime(); int hashCode = entry.hashCode(); StringBuffer out = new StringBuffer(); out.append( "Name: " + name + "\n" ); out.append( " Size: " + Long.toHexString( size ) + " " ); out.append( " Compressed Size: " + Long.toHexString( compressedSize ) + " " ); out.append( " Compression Method: " + compressMethod + " " ); out.append( " Timestamp: " + Long.toHexString( timeStamp ) + " " ); out.append( " HashCode: " + Integer.toHexString( hashCode ) + " " ); out.append( " CRC: " + Long.toHexString( crc ) + " " ); System.out.println( out.toString() ); } } catch ( Exception e ) { throw new BuildException( e.getMessage(), e ); } }