Java Code Examples for com.android.dex.util.FileUtils#readFile()

The following examples show how to use com.android.dex.util.FileUtils#readFile() . 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: ClassPathOpener.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * 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 2
Source File: ClassPathOpener.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * 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: ClassPathOpener.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * 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 4
Source File: ClassPathOpener.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
    }
}