Java Code Examples for java.util.jar.JarInputStream#available()
The following examples show how to use
java.util.jar.JarInputStream#available() .
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: Utilities.java From AVM with MIT License | 5 votes |
public static Map<String, byte[]> extractClasses(JarInputStream jarReader, NameStyle nameStyle) throws IOException { Map<String, byte[]> classMap = new HashMap<>(); byte[] tempReadingBuffer = new byte[MAX_CLASS_BYTES]; JarEntry entry; while (null != (entry = jarReader.getNextJarEntry())) { String name = entry.getName(); if (name.endsWith(".class") && !name.equals("package-info.class") && !name.equals("module-info.class")) { String internalClassName = name.replaceAll(".class$", ""); if (nameStyle.equals(NameStyle.DOT_NAME)) { internalClassName = Utilities.internalNameToFulllyQualifiedName(internalClassName); } int readSize = jarReader.readNBytes(tempReadingBuffer, 0, tempReadingBuffer.length); if (0 != jarReader.available()) { throw new RuntimeException("Class file too big: " + name); } byte[] classBytes = new byte[readSize]; System.arraycopy(tempReadingBuffer, 0, classBytes, 0, readSize); classMap.put(internalClassName, classBytes); } } return classMap; }
Example 2
Source File: WLJpa2SwitchSupport.java From netbeans with Apache License 2.0 | 5 votes |
private void replaceManifest(InputStream is, OutputStream os, Manifest manifest) throws IOException { JarInputStream in = new JarInputStream(is); try { JarOutputStream out = new JarOutputStream(os, manifest); try { JarEntry entry = null; byte[] temp = new byte[32768]; while ((entry = in.getNextJarEntry()) != null) { String name = entry.getName(); if (name.equalsIgnoreCase("META-INF/MANIFEST.MF")) { // NOI18N continue; } out.putNextEntry(entry); while (in.available() != 0) { int read = in.read(temp); if (read != -1) { out.write(temp, 0, read); } } out.closeEntry(); } } finally { out.close(); } } finally { in.close(); } }
Example 3
Source File: Maracas.java From scava with Eclipse Public License 2.0 | 5 votes |
private boolean unzipJarAlt(String pathJar, String pathDir) { try { FileInputStream fileStream = new FileInputStream(File.separator + pathJar); JarInputStream jarStream = new JarInputStream(fileStream); JarEntry entry = jarStream.getNextJarEntry(); while (entry != null) { File fileEntry = new File(File.separator + pathDir + File.separator + entry.getName()); if (entry.isDirectory()) { fileEntry.mkdirs(); } else { FileOutputStream os = new FileOutputStream(fileEntry); while (jarStream.available() > 0) { os.write(jarStream.read()); } os.close(); } entry = jarStream.getNextJarEntry(); } jarStream.close(); return true; } catch (IOException e) { e.printStackTrace(); } return false; }
Example 4
Source File: JarResource.java From org.openntf.domino with Apache License 2.0 | 5 votes |
@Override public Map<String, byte[]> getClassData() { byte[] jarData = getFileData(); try { ByteArrayInputStream bis = new ByteArrayInputStream(jarData); JarInputStream jis = new JarInputStream(bis); JarEntry entry = jis.getNextJarEntry(); Map<String, byte[]> classData = new HashMap<String, byte[]>(); while (entry != null) { String name = entry.getName(); if (name.endsWith(".class")) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); while (jis.available() > 0) { bos.write(jis.read()); } classData.put(DominoUtils.filePathToJavaBinaryName(name, "/"), bos.toByteArray()); } entry = jis.getNextJarEntry(); } jis.close(); return classData; } catch (IOException ioe) { DominoUtils.handleException(ioe); return null; } }
Example 5
Source File: ScriptLibraryJava.java From org.openntf.domino with Apache License 2.0 | 5 votes |
@Override public Map<String, byte[]> getClassData() { // For this one, we'll need the note in the database if (classData == null) { classData = new TreeMap<String, byte[]>(); try { byte[] jarData = getFileDataRaw("%%object%%.jar"); InputStream objInputStream = new ByteArrayInputStream(jarData); JarInputStream jis = new JarInputStream(objInputStream); JarEntry entry = jis.getNextJarEntry(); while (entry != null) { String name = entry.getName(); if (name.endsWith(".class")) { //TODO our classloader should support resources also! ByteArrayOutputStream bos = new ByteArrayOutputStream(); while (jis.available() > 0) { bos.write(jis.read()); } classData.put(DominoUtils.filePathToJavaBinaryName(name, "/"), bos.toByteArray()); } entry = jis.getNextJarEntry(); } jis.close(); objInputStream.close(); } catch (Exception e) { e.printStackTrace(); } } return classData; }