当前位置: 首页>>代码示例>>Java>>正文


Java UncheckedIOException类代码示例

本文整理汇总了Java中org.gradle.api.UncheckedIOException的典型用法代码示例。如果您正苦于以下问题:Java UncheckedIOException类的具体用法?Java UncheckedIOException怎么用?Java UncheckedIOException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UncheckedIOException类属于org.gradle.api包,在下文中一共展示了UncheckedIOException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeTo

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
@Deprecated
@Override
public DefaultManifest writeTo(Writer writer) {
    SingleMessageLogger.nagUserOfDeprecated("Manifest.writeTo(Writer)", "Please use Manifest.writeTo(Object) instead");
    try {
        Manifest javaManifest = generateJavaManifest(getEffectiveManifest());
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        javaManifest.write(buffer);
        String manifestContent = buffer.toString(DEFAULT_CONTENT_CHARSET);
        if (!DEFAULT_CONTENT_CHARSET.equals(contentCharset)) {
            // Convert the UTF-8 manifest bytes to the requested content charset
            manifestContent = new String(manifestContent.getBytes(contentCharset), contentCharset);
        }
        writer.write(manifestContent);
        writer.flush();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return this;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:DefaultManifest.java

示例2: read

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
private void read(Object manifestPath) {
    File manifestFile = fileResolver.resolve(manifestPath);
    try {
        byte[] manifestBytes = FileUtils.readFileToByteArray(manifestFile);
        manifestBytes = prepareManifestBytesForInteroperability(manifestBytes);
        // Eventually convert manifest content to UTF-8 before handing it to java.util.jar.Manifest
        if (!DEFAULT_CONTENT_CHARSET.equals(contentCharset)) {
            manifestBytes = new String(manifestBytes, contentCharset).getBytes(DEFAULT_CONTENT_CHARSET);
        }
        // Effectively read the manifest
        Manifest javaManifest = new Manifest(new ByteArrayInputStream(manifestBytes));
        addJavaManifestToAttributes(javaManifest);
        addJavaManifestToSections(javaManifest);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:DefaultManifest.java

示例3: exec

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
@TaskAction
void exec() {
  getProject().exec(new Action<ExecSpec>() {
    @Override
    public void execute(ExecSpec execSpec) {
      try {
        if (dexMergerExecutable == null) {
          dexMergerExecutable = Utils.dexMergerExecutable();
        }
        execSpec.setExecutable(dexMergerExecutable);
        execSpec.args(destination.getCanonicalPath());
        execSpec.args(source.getFiles());
      } catch (IOException e) {
        throw new UncheckedIOException(e);
      }
    }
  });
}
 
开发者ID:inferjay,项目名称:r8,代码行数:19,代码来源:DexMerger.java

示例4: createHash

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
public static HashValue createHash(InputStream instr, String algorithm) {
    MessageDigest messageDigest;
    try {
        messageDigest = createMessageDigest(algorithm);
        byte[] buffer = new byte[4096];
        try {
            while (true) {
                int nread = instr.read(buffer);
                if (nread < 0) {
                    break;
                }
                messageDigest.update(buffer, 0, nread);
            }
        } finally {
            instr.close();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return new HashValue(messageDigest.digest());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:22,代码来源:HashUtil.java

示例5: execute

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
public void execute(Action<? super BufferedWriter> action) {
    try {
        File parentFile = file.getParentFile();
        if (parentFile != null) {
            if (!parentFile.mkdirs() && !parentFile.isDirectory()) {
                throw new IOException(String.format("Unable to create directory '%s'", parentFile));
            }
        }
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), encoding));
        try {
            action.execute(writer);
        } finally {
            writer.close();
        }
    } catch (Exception e) {
        throw new UncheckedIOException(String.format("Could not write to file '%s'.", file), e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:IoActions.java

示例6: argsFileGenerator

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
/**
 * Returns an args transformer that replaces the provided args with a generated args file containing the args. Uses platform text encoding.
 */
public static Transformer<List<String>, List<String>> argsFileGenerator(final File argsFile, final Transformer<ArgWriter, PrintWriter> argWriterFactory) {
    return new Transformer<List<String>, List<String>>() {
        @Override
        public List<String> transform(List<String> args) {
            if (args.isEmpty()) {
                return args;
            }
            argsFile.getParentFile().mkdirs();
            try {
                PrintWriter writer = new PrintWriter(argsFile);
                try {
                    ArgWriter argWriter = argWriterFactory.transform(writer);
                    argWriter.args(args);
                } finally {
                    writer.close();
                }
            } catch (IOException e) {
                throw new UncheckedIOException(String.format("Could not write options file '%s'.", argsFile.getAbsolutePath()), e);
            }
            return Collections.singletonList("@" + argsFile.getAbsolutePath());
        }
    };
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:27,代码来源:ArgWriter.java

示例7: create

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
public Properties create() {
    URL resource = classLoader.getResource(resourceName);
    if (resource == null) {
        throw new RuntimeException(
                "Unable to find the released versions information.\n"
                        + "The resource '" + resourceName + "' was not found.\n"
                        + "Most likely, you haven't run the 'prepareVersionsInfo' task.\n"
                        + "If you have trouble running tests from your IDE, please run gradlew idea|eclipse first."
        );
    }

    try {
        Properties properties = new Properties();
        InputStream stream = resource.openStream();
        try {
            properties.load(stream);
        } finally {
            stream.close();
        }
        return properties;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:25,代码来源:ClasspathVersionSource.java

示例8: readFrom

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
@Override
public boolean readFrom(Object path) {
    if (fileResolver == null) {
        return false;
    }
    File descriptorFile = fileResolver.resolve(path);
    if (descriptorFile == null || !descriptorFile.exists()) {
        return false;
    }
    try {
        FileReader reader = new FileReader(descriptorFile);
        readFrom(reader);
        return true;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:DefaultDeploymentDescriptor.java

示例9: printDaemonStarted

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
public void printDaemonStarted(PrintStream target, Long pid, String uid, Address address, File daemonLog) {
    target.print(daemonGreeting());

    // Encode as ascii
    try {
        OutputStream outputStream = new EncodedStream.EncodedOutput(target);
        FlushableEncoder encoder = new OutputStreamBackedEncoder(outputStream);
        encoder.writeNullableString(pid == null ? null : pid.toString());
        encoder.writeString(uid);
        MultiChoiceAddress multiChoiceAddress = (MultiChoiceAddress) address;
        new MultiChoiceAddressSerializer().write(encoder, multiChoiceAddress);
        encoder.writeString(daemonLog.getPath());
        encoder.flush();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }

    target.println();

    //ibm vm 1.6 + windows XP gotchas:
    //we need to print something else to the stream after we print the daemon greeting.
    //without it, the parent hangs without receiving the message above (flushing does not help).
    LOGGER.debug("Completed writing the daemon greeting. Closing streams...");
    //btw. the ibm vm+winXP also has some issues detecting closed streams by the child but we handle this problem differently.
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:26,代码来源:DaemonStartupCommunication.java

示例10: readDiagnostics

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
public DaemonStartupInfo readDiagnostics(String message) {
    //Assuming the message has correct format. Not bullet proof, but seems to work ok for now.
    if (!message.startsWith(daemonGreeting())) {
        throw new IllegalArgumentException(String.format("Unexpected daemon startup message: %s", message));
    }
    try {
        String encoded = message.substring(daemonGreeting().length()).trim();
        InputStream inputStream = new EncodedStream.EncodedInput(new ByteArrayInputStream(encoded.getBytes()));
        Decoder decoder = new InputStreamBackedDecoder(inputStream);
        String pidString = decoder.readNullableString();
        String uid = decoder.readString();
        Long pid = pidString == null ? null : Long.valueOf(pidString);
        Address address = new MultiChoiceAddressSerializer().read(decoder);
        File daemonLog = new File(decoder.readString());
        return new DaemonStartupInfo(uid, address, new DaemonDiagnostics(daemonLog, pid));
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:DaemonStartupCommunication.java

示例11: maybeConfigureFrom

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
private void maybeConfigureFrom(File propertiesFile, Map<String, String> result) {
    if (!propertiesFile.isFile()) {
        return;
    }

    Properties properties = new Properties();
    try {
        FileInputStream inputStream = new FileInputStream(propertiesFile);
        try {
            properties.load(inputStream);
        } finally {
            inputStream.close();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }

    for (Object key : properties.keySet()) {
        if (GradleProperties.ALL.contains(key.toString())) {
            result.put(key.toString(), properties.get(key).toString());
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:24,代码来源:LayoutToPropertiesConverter.java

示例12: parse

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
public static Scriptable parse(File source, String encoding, Action<Context> contextConfig) {
    Context context = Context.enter();
    if (contextConfig != null) {
        contextConfig.execute(context);
    }

    Scriptable scope = context.initStandardObjects();
    try {
        Reader reader = new InputStreamReader(new FileInputStream(source), encoding);
        try {
            context.evaluateReader(scope, reader, source.getName(), 0, null);
        } finally {
            reader.close();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    } finally {
        Context.exit();
    }

    return scope;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:RhinoWorkerUtils.java

示例13: parseJavaVersionCommandOutput

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
private JavaVersion parseJavaVersionCommandOutput(String javaExecutable, BufferedReader reader) {
    try {
        String versionStr = reader.readLine();
        while (versionStr != null) {
            Matcher matcher = Pattern.compile("(?:java|openjdk) version \"(.+?)\"").matcher(versionStr);
            if (matcher.matches()) {
                return JavaVersion.toVersion(matcher.group(1));
            }
            versionStr = reader.readLine();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }

    throw new GradleException(String.format("Could not determine Java version using executable %s.", javaExecutable));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:DefaultJvmVersionDetector.java

示例14: saveSettings

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
/**
 * Saves the settings of the file chooser; and by settings I mean the 'last visited directory'.
 *
 * @param saveCurrentDirectoryVsSelectedFilesParent this should be true if you're selecting only directories, false if you're selecting only files. I don't know what if you allow both.
 */
public static void saveSettings(SettingsNode settingsNode, JFileChooser fileChooser, String id, Class fileChooserClass, boolean saveCurrentDirectoryVsSelectedFilesParent) {
    SettingsNode childNode = settingsNode.addChildIfNotPresent(getPrefix(fileChooserClass, id));

    String save;
    try {
        if (saveCurrentDirectoryVsSelectedFilesParent) {
            save = fileChooser.getCurrentDirectory().getCanonicalPath();
        } else {
            save = fileChooser.getSelectedFile().getCanonicalPath();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    if (save != null) {
        childNode.setValueOfChild(DIRECTORY_NAME, save);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:PreferencesAssistant.java

示例15: extractInitScriptFile

import org.gradle.api.UncheckedIOException; //导入依赖的package包/类
/**
 * If you do have an init script that's a resource, this will extract it based on the name and write it to a temporary file and delete it on exit.
 *
 * @param resourceClass the class associated with the resource
 * @param resourceName the name (minus extension or '.') of the resource
 */
protected File extractInitScriptFile(Class resourceClass, String resourceName) {
    File file = null;
    try {
        file = temporaryFileProvider.createTemporaryFile(resourceName, INIT_SCRIPT_EXTENSION);
    } catch (UncheckedIOException e) {
        logger.error("Creating init script file temp file", e);
        return null;
    }
    file.deleteOnExit();

    if (extractResourceAsFile(resourceClass, resourceName + INIT_SCRIPT_EXTENSION, file)) {
        return file;
    }

    logger.error("Internal error! Failed to extract init script for executing commands!");

    return null;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:25,代码来源:AbstractGradleServerProtocol.java


注:本文中的org.gradle.api.UncheckedIOException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。