Example usage for java.io UncheckedIOException UncheckedIOException

List of usage examples for java.io UncheckedIOException UncheckedIOException

Introduction

In this page you can find the example usage for java.io UncheckedIOException UncheckedIOException.

Prototype

public UncheckedIOException(IOException cause) 

Source Link

Document

Constructs an instance of this class.

Usage

From source file:com.github.blindpirate.gogradle.util.IOUtils.java

public static String toString(InputStream inputStream) {
    try {//  w  ww .  j  av  a 2 s  .com
        return org.apache.commons.io.IOUtils.toString(inputStream, DEFAULT_CHARSET);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:org.trellisldp.rdfa.HtmlSerializer.java

/**
 * Send the content to an output stream.
 *
 * @param triples the triples//from w w w. ja v a  2  s .c  o  m
 * @param out the output stream
 * @param subject the subject
 */
@Override
public void write(final Stream<Triple> triples, final OutputStream out, final String subject) {
    final Writer writer = new OutputStreamWriter(out, UTF_8);
    try {
        template.execute(writer,
                new HtmlData(namespaceService, subject, triples.collect(toList()), css, js, icon)).flush();
    } catch (final IOException ex) {
        throw new UncheckedIOException(ex);
    }
}

From source file:org.springframework.cloud.function.deployer.FunctionCreatorConfiguration.java

private URL toUrl(String url) {
    if (url.equals("app:classpath")) {
        return urls()[0];
    }/*from   ww w.jav  a 2 s .  c  o m*/
    try {
        return new URL(url);
    } catch (MalformedURLException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:am.ik.categolj3.api.git.GitStore.java

ObjectId head() {
    try (Repository repository = this.git.getRepository()) {
        return repository.resolve("HEAD");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }/*  ww w.j  a  va  2s .  com*/
}

From source file:org.culturegraph.mf.xml.XmlFilenameWriter.java

private OutputStream createBZip2Compressor(OutputStream stream) {
    try {//  w w w  .  j a  va  2  s . c  o  m
        return new BZip2CompressorOutputStream(stream);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.indoqa.httpproxy.HttpClientProxy.java

private void writeProxyErrorResponse(HttpServletResponse response, IOException exception) {
    try {//from w w  w. ja va2  s  . c  o  m
        response.sendError(SC_INTERNAL_SERVER_ERROR, exception.getMessage());
    } catch (IOException e) {
        throw new UncheckedIOException(exception);
    }
}

From source file:com.discovery.darchrow.io.IOWriteUtil.java

/**
 * NIO API ?? ().//from   ww  w  . j av a2 s. c o m
 *
 * @param bufferLength
 *            the buffer length
 * @param inputStream
 *            the input stream
 * @param outputStream
 *            the output stream
 * @since 1.0.8
 * @since jdk1.4
 */
private static void writeUseNIO(int bufferLength, InputStream inputStream, OutputStream outputStream) {
    int i = 0;
    int sumSize = 0;
    int j = 0;

    ///2 
    //As creme de la creme with regard to performance, you could use NIO Channels and ByteBuffer. 

    ReadableByteChannel readableByteChannel = Channels.newChannel(inputStream);
    WritableByteChannel writableByteChannel = Channels.newChannel(outputStream);

    ByteBuffer byteBuffer = ByteBuffer.allocate(bufferLength);

    try {
        while (readableByteChannel.read(byteBuffer) != -1) {
            byteBuffer.flip();
            j = writableByteChannel.write(byteBuffer);
            sumSize += j;
            byteBuffer.clear();
            i++;
        }

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Write data over,sumSize:[{}],bufferLength:[{}],loopCount:[{}]",
                    FileUtil.formatSize(sumSize), bufferLength, i);
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    } finally {
        IOUtils.closeQuietly(outputStream);
        IOUtils.closeQuietly(writableByteChannel);
        IOUtils.closeQuietly(inputStream);
        IOUtils.closeQuietly(readableByteChannel);
    }
}

From source file:com.discovery.darchrow.io.FileUtil.java

/**
 *  {@link java.io.FileOutputStream} ?  .<br>
 * {@link java.io.FileOutputStream} ???.<br>
 * ?? {@link java.io.FileWriter}./*from   w  ww.  j a  va  2s .co  m*/
 *
 * @param filePath
 *            the file path
 * @param append
 *            if true, then bytes will be written to the end of the file rather than the beginning
 * @return the file output stream
 * @see java.io.FileOutputStream#FileOutputStream(String, boolean)
 * @since 1.2.0
 */
// Access Modifiers ??
static final FileOutputStream getFileOutputStream(String filePath, boolean append) {
    try {
        FileOutputStream fileOutputStream = new FileOutputStream(filePath, append);
        return fileOutputStream;
    } catch (FileNotFoundException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.github.anba.es6draft.chakra.ChakraTest.java

private static Map<String, TestSetting> readSettings(Path dir) {
    Path settingsFile = dir.resolve("rlexe.xml");
    if (Files.isRegularFile(settingsFile)) {
        try (Reader reader = bomReader(Files.newInputStream(settingsFile))) {
            Document doc = Resources.xml(reader);
            NodeList elements = doc.getElementsByTagName("default");
            HashMap<String, TestSetting> settingMap = new HashMap<>();
            for (int i = 0, length = elements.getLength(); i < length; ++i) {
                Element element = (Element) elements.item(i);
                String files = element.getElementsByTagName("files").item(0).getTextContent();
                TestSetting setting = new TestSetting();
                NodeList baseline = element.getElementsByTagName("baseline");
                if (baseline.getLength() > 0) {
                    setting.baseline = baseline.item(0).getTextContent();
                }/*from   ww w  . j a va 2  s  .c  om*/
                NodeList compileFlags = element.getElementsByTagName("compile-flags");
                if (compileFlags.getLength() > 0) {
                    String flags = compileFlags.item(0).getTextContent();
                    setting.disabled = flags.contains("-verbose") || flags.contains("-dump:")
                            || flags.contains("-trace:") || flags.contains("-testtrace:")
                            || flags.contains("-testTrace:");
                }
                settingMap.putIfAbsent(files, setting);
            }
            return settingMap;
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
    return Collections.emptyMap();
}

From source file:com.github.blindpirate.gogradle.util.IOUtils.java

public static void append(File file, String str) {
    try {//from  ww  w.jav a 2s.c o  m
        FileUtils.write(file, str, GogradleGlobal.DEFAULT_CHARSET, true);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}