com.android.dex.util.FileUtils Java Examples
The following examples show how to use
com.android.dex.util.FileUtils.
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: Dex.java From Box with Apache License 2.0 | 6 votes |
/** * Creates a new dex buffer from the dex file {@code file}. */ public Dex(File file) throws IOException { if (FileUtils.hasArchiveSuffix(file.getName())) { ZipFile zipFile = new ZipFile(file); ZipEntry entry = zipFile.getEntry(DexFormat.DEX_IN_JAR_NAME); if (entry != null) { try (InputStream inputStream = zipFile.getInputStream(entry)) { loadFrom(inputStream); } zipFile.close(); } else { throw new DexException("Expected " + DexFormat.DEX_IN_JAR_NAME + " in " + file); } } else if (file.getName().endsWith(".dex")) { try (InputStream inputStream = new FileInputStream(file)) { loadFrom(inputStream); } } else { throw new DexException("unknown output extension: " + file); } }
Example #2
Source File: ClassPathOpener.java From Box with Apache License 2.0 | 6 votes |
/** * Processes one file. * * @param file {@code non-null;} the file to process * @param topLevel whether this is a top-level file (that is, * specified directly on the commandline) * @return whether any processing actually happened */ private boolean processOne(File file, boolean topLevel) { try { if (file.isDirectory()) { return processDirectory(file, topLevel); } String path = file.getPath(); if (path.endsWith(".zip") || path.endsWith(".jar") || path.endsWith(".apk")) { return processArchive(file); } if (filter.accept(path)) { byte[] bytes = FileUtils.readFile(file); return consumer.processFileBytes(path, file.lastModified(), bytes); } else { return false; } } catch (Exception ex) { consumer.onException(ex); return false; } }
Example #3
Source File: Dex.java From Box with Apache License 2.0 | 6 votes |
/** * Creates a new dex buffer from the dex file {@code file}. */ public Dex(File file) throws IOException { if (FileUtils.hasArchiveSuffix(file.getName())) { ZipFile zipFile = new ZipFile(file); ZipEntry entry = zipFile.getEntry(DexFormat.DEX_IN_JAR_NAME); if (entry != null) { try (InputStream inputStream = zipFile.getInputStream(entry)) { loadFrom(inputStream); } zipFile.close(); } else { throw new DexException("Expected " + DexFormat.DEX_IN_JAR_NAME + " in " + file); } } else if (file.getName().endsWith(".dex")) { try (InputStream inputStream = new FileInputStream(file)) { loadFrom(inputStream); } } else { throw new DexException("unknown output extension: " + file); } }
Example #4
Source File: ClassPathOpener.java From Box with Apache License 2.0 | 6 votes |
/** * Processes one file. * * @param file {@code non-null;} the file to process * @param topLevel whether this is a top-level file (that is, * specified directly on the commandline) * @return whether any processing actually happened */ private boolean processOne(File file, boolean topLevel) { try { if (file.isDirectory()) { return processDirectory(file, topLevel); } String path = file.getPath(); if (path.endsWith(".zip") || path.endsWith(".jar") || path.endsWith(".apk")) { return processArchive(file); } if (filter.accept(path)) { byte[] bytes = FileUtils.readFile(file); return consumer.processFileBytes(path, file.lastModified(), bytes); } else { return false; } } catch (Exception ex) { consumer.onException(ex); return false; } }
Example #5
Source File: Dex.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Creates a new dex buffer from the dex file {@code file}. */ public Dex(File file) throws IOException { if (FileUtils.hasArchiveSuffix(file.getName())) { ZipFile zipFile = new ZipFile(file); ZipEntry entry = zipFile.getEntry(DexFormat.DEX_IN_JAR_NAME); if (entry != null) { try (InputStream inputStream = zipFile.getInputStream(entry)) { loadFrom(inputStream); } zipFile.close(); } else { throw new DexException("Expected " + DexFormat.DEX_IN_JAR_NAME + " in " + file); } } else if (file.getName().endsWith(".dex")) { try (InputStream inputStream = new FileInputStream(file)) { loadFrom(inputStream); } } else { throw new DexException("unknown output extension: " + file); } }
Example #6
Source File: ClassPathOpener.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Processes one file. * * @param file {@code non-null;} the file to process * @param topLevel whether this is a top-level file (that is, * specified directly on the commandline) * @return whether any processing actually happened */ private boolean processOne(File file, boolean topLevel) { try { if (file.isDirectory()) { return processDirectory(file, topLevel); } String path = file.getPath(); if (path.endsWith(".zip") || path.endsWith(".jar") || path.endsWith(".apk")) { return processArchive(file); } if (filter.accept(path)) { byte[] bytes = FileUtils.readFile(file); return consumer.processFileBytes(path, file.lastModified(), bytes); } else { return false; } } catch (Exception ex) { consumer.onException(ex); return false; } }
Example #7
Source File: Dex.java From aapt with Apache License 2.0 | 6 votes |
/** * Creates a new dex buffer from the dex file {@code file}. */ public Dex(File file) throws IOException { if (FileUtils.hasArchiveSuffix(file.getName())) { ZipFile zipFile = new ZipFile(file); ZipEntry entry = zipFile.getEntry(DexFormat.DEX_IN_JAR_NAME); try { if (entry != null) { try (InputStream inputStream = zipFile.getInputStream(entry)) { loadFrom(inputStream); } } else { throw new DexException("Expected " + DexFormat.DEX_IN_JAR_NAME + " in " + file); } } finally { zipFile.close(); } } else if (file.getName().endsWith(".dex")) { try (InputStream inputStream = new FileInputStream(file)) { loadFrom(inputStream); } } else { throw new DexException("unknown output extension: " + file); } }
Example #8
Source File: Dex.java From buck with Apache License 2.0 | 6 votes |
/** * Creates a new dex buffer from the dex file {@code file}. */ public Dex(File file) throws IOException { if (FileUtils.hasArchiveSuffix(file.getName())) { ZipFile zipFile = new ZipFile(file); ZipEntry entry = zipFile.getEntry(DexFormat.DEX_IN_JAR_NAME); if (entry != null) { loadFrom(zipFile.getInputStream(entry)); zipFile.close(); } else { throw new DexException("Expected " + DexFormat.DEX_IN_JAR_NAME + " in " + file); } } else if (file.getName().endsWith(".dex")) { loadFrom(new FileInputStream(file)); } else { throw new DexException("unknown output extension: " + file); } }
Example #9
Source File: ClassPathOpener.java From buck with Apache License 2.0 | 6 votes |
/** * Processes one file. * * @param file {@code non-null;} the file to process * @param topLevel whether this is a top-level file (that is, * specified directly on the commandline) * @return whether any processing actually happened */ private boolean processOne(File file, boolean topLevel) { try { if (file.isDirectory()) { return processDirectory(file, topLevel); } String path = file.getPath(); if (path.endsWith(".zip") || path.endsWith(".jar") || path.endsWith(".apk")) { return processArchive(file); } if (filter.accept(path)) { byte[] bytes = FileUtils.readFile(file); return consumer.processFileBytes(path, file.lastModified(), bytes); } else { return false; } } catch (Exception ex) { consumer.onException(ex); return false; } }