org.gradle.internal.impldep.org.apache.commons.io.IOUtils Java Examples

The following examples show how to use org.gradle.internal.impldep.org.apache.commons.io.IOUtils. 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: FindAndroidVisitor.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public static final boolean visit(File buildGradle) throws FileNotFoundException, IOException {
    AstBuilder builder = new AstBuilder();
    List<ASTNode> nodes = builder.buildFromString(IOUtils.toString(new FileInputStream(buildGradle), "UTF-8"));
    FindAndroidVisitor visitor = new FindAndroidVisitor();
    for (ASTNode node : nodes) {
        node.visit(visitor);
    }
    return visitor.androidProject;
}
 
Example #2
Source File: FindRepositoriesVisitor.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public static final List<Repository> visit(File buildGradle) throws FileNotFoundException, IOException {
    AstBuilder builder = new AstBuilder();
    List<ASTNode> nodes = builder.buildFromString(IOUtils.toString(new FileInputStream(buildGradle), "UTF-8"));
    FindRepositoriesVisitor visitor = new FindRepositoriesVisitor();
    for (ASTNode node : nodes) {
        node.visit(visitor);
    }
    return visitor.repositories;
}
 
Example #3
Source File: AndroidGradleDependenciesVisitor.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public static AndroidGradleDependenciesVisitor parse(File file) throws IOException {
    AstBuilder builder = new AstBuilder();
    AndroidGradleDependenciesVisitor visitor = new AndroidGradleDependenciesVisitor();
    List<ASTNode> nodes = builder.buildFromString(IOUtils.toString(new FileInputStream(file), "UTF-8"));
    for (ASTNode node : nodes) {
        visitor.setRootBlockStatement((BlockStatement) node);
        node.visit(visitor);
    }
    return visitor;
}
 
Example #4
Source File: MavenDownloader.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public static void unzip(File zipFile, File destination)
        throws IOException {
    ZipFile zip = new ZipFile(zipFile);
    try {
        Enumeration<ZipArchiveEntry> e = zip.getEntries();
        while (e.hasMoreElements()) {
            ZipArchiveEntry entry = e.nextElement();
            File file = new File(destination, entry.getName());
            if (entry.isDirectory()) {
                file.mkdirs();
            } else {
                InputStream is = zip.getInputStream(entry);
                File parent = file.getParentFile();
                if (parent != null && parent.exists() == false) {
                    parent.mkdirs();
                }
                FileOutputStream os = new FileOutputStream(file);
                try {
                    IOUtils.copy(is, os);
                } finally {
                    os.close();
                    is.close();
                }
                file.setLastModified(entry.getTime());
                int mode = entry.getUnixMode();
                if ((mode & EXEC_MASK) != 0) {
                    if (!file.setExecutable(true)) {
                    }
                }
            }
        }
    } finally {
        ZipFile.closeQuietly(zip);
    }
}
 
Example #5
Source File: FunctionalDownloadTest.java    From gradle-download-task with Apache License 2.0 5 votes vote down vote up
/**
 * Kill a process by its PID
 * @param pid the PID
 * @throws IOException if the `kill` command could not be executed
 */
private static void killProcess(String pid) throws IOException {
    ProcessBuilder builder = new ProcessBuilder("kill", pid);
    builder.redirectErrorStream(true);
    Process process = builder.start();
    InputStream is = process.getInputStream();
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    IOUtils.skip(reader, Long.MAX_VALUE);
}
 
Example #6
Source File: ReportsRoundtripTest.java    From gradle-golang-plugin with Mozilla Public License 2.0 4 votes vote down vote up
@Nonnull
protected String resultContentOf(@Nonnull String test) throws IOException {
    try (final Reader reader = resultReaderOf(test)) {
        return IOUtils.toString(reader);
    }
}