Example usage for java.io IOException IOException

List of usage examples for java.io IOException IOException

Introduction

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

Prototype

public IOException(String message, Throwable cause) 

Source Link

Document

Constructs an IOException with the specified detail message and cause.

Usage

From source file:com.yahoo.yqlplus.example.apis.Programs.java

public static String runProgram(String path, Map<String, Object> params) throws IOException {
    try {/* ww w.jav  a 2s.  c  o m*/
        Object results = programMap.get(path).run(params, true).getResult("weather").get().getResult();
        return HttpUtil.getGson().toJson(results);
    } catch (Exception e) {
        throw new IOException("Executing program failed", e);
    }
}

From source file:com.skcraft.launcher.builder.Compressor.java

public InputStream createInputStream(InputStream inputStream) throws IOException {
    try {/* www.  j a v  a 2s . com*/
        return factory.createCompressorInputStream(format, inputStream);
    } catch (CompressorException e) {
        throw new IOException("Failed to create decompressor", e);
    }
}

From source file:fitnesse.slimTables.HtmlTableScanner.java

public HtmlTableScanner(String page) throws IOException {
    if (isEmpty(page))
        page = "<i>This page intentionally left blank.</i>";

    Parser parser = new Parser(new Lexer(new Page(page)));
    try {/*w  w  w .ja v a  2s.  c o m*/
        htmlTree = parser.parse(null);
    } catch (ParserException e) {
        throw new IOException("Could not read HTML content", e);
    }
    scanForTables(htmlTree);
}

From source file:Main.java

/** Issue a POST with exponential backoff */
private static String post(String endpoint, Map<String, String> params, int maxAttempts) throws IOException {
    long backoff = BACKOFF_MILLI_SECONDS + random.nextInt(1000);
    for (int i = 1; i <= maxAttempts; i++) {
        Log.d(TAG, "Attempt #" + i + " to connect");
        try {/*  w w w. j a v a  2s .  c om*/
            return executePost(endpoint, params);
        } catch (IOException e) {
            Log.e(TAG, "Failed on attempt " + i + ":" + e);
            if (i == maxAttempts) {
                throw e;
            }
            try {
                Thread.sleep(backoff);
            } catch (InterruptedException e1) {
                Thread.currentThread().interrupt();
                return null;
            }
            backoff *= 2;
        } catch (IllegalArgumentException e) {
            throw new IOException(e.getMessage(), e);
        }
    }
    return null;
}

From source file:com.uber.hoodie.utilities.UtilHelpers.java

public static Source createSource(String sourceClass, PropertiesConfiguration cfg, JavaSparkContext jssc,
        SourceDataFormat dataFormat, SchemaProvider schemaProvider) throws IOException {
    try {// w  w w  .j  ava 2s .c  om
        return (Source) ConstructorUtils.invokeConstructor(Class.forName(sourceClass), (Object) cfg,
                (Object) jssc, (Object) dataFormat, (Object) schemaProvider);
    } catch (Throwable e) {
        throw new IOException("Could not load source class " + sourceClass, e);
    }
}

From source file:com.trin.nilmobile.serializer.ObjectSerializer.java

public static Object deserialize(String str) throws IOException {
    if (str == null || str.length() == 0)
        return null;
    try {/* w  ww.j  a v  a 2 s.c om*/
        ByteArrayInputStream serialObj = new ByteArrayInputStream(decodeBytes(str));
        ObjectInputStream objStream = new ObjectInputStream(serialObj);
        return objStream.readObject();
    } catch (Exception e) {
        throw new IOException("Deserialization error: " + e.getMessage(), e);
    }
}

From source file:com.asakusafw.shafu.core.net.ShafuNetwork.java

/**
 * Processes a content on the target URL.
 * @param url the target URL//from  ww  w .ja  va2  s . c  o  m
 * @param processor the content processor
 * @param <T> the processing result type
 * @return the process result
 * @throws IOException if failed to process the content
 */
public static <T> T processContent(URL url, IContentProcessor<? extends T> processor) throws IOException {
    String protocol = url.getProtocol();
    if (protocol != null && HTTP_SCHEMES.contains(protocol)) {
        return processHttpContent(url, processor);
    }
    InputStream input;
    try {
        input = url.openStream();
    } catch (IOException e) {
        throw new IOException(MessageFormat.format(Messages.ShafuNetwork_failedToOpenContent, url), e);
    }
    try {
        return processor.process(input);
    } finally {
        input.close();
    }
}

From source file:be.fedict.eid.tsl.TrustServiceListFactory.java

/**
 * Creates a new trust service list from the given file.
 * /*  w  w  w .  ja  v  a 2 s.  co  m*/
 * @param tslFile
 * @return
 * @throws IOException
 */
public static TrustServiceList newInstance(File tslFile) throws IOException {
    if (null == tslFile) {
        throw new IllegalArgumentException();
    }
    Document tslDocument;
    try {
        tslDocument = parseDocument(tslFile);
    } catch (Exception e) {
        throw new IOException("DOM parse error: " + e.getMessage(), e);
    }
    TrustServiceList trustServiceList = newInstance(tslDocument, tslFile);
    return trustServiceList;
}

From source file:Main.java

/**
 * This will parse an XML stream and create a DOM document.
 *
 * @param is The stream to get the XML from.
 * @return The DOM document./*from   www .jav a2 s . c  o m*/
 * @throws IOException It there is an error creating the dom.
 */
public static Document parse(InputStream is) throws IOException {
    try {
        DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
        builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
        builderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
        builderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
        builderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
        builderFactory.setXIncludeAware(false);
        builderFactory.setExpandEntityReferences(false);
        DocumentBuilder builder = builderFactory.newDocumentBuilder();
        return builder.parse(is);
    } catch (FactoryConfigurationError e) {
        throw new IOException(e.getMessage(), e);
    } catch (ParserConfigurationException e) {
        throw new IOException(e.getMessage(), e);
    } catch (SAXException e) {
        throw new IOException(e.getMessage(), e);
    }
}

From source file:com.ikanow.infinit.e.harvest.extraction.document.file.InfiniteFile.java

public static InfiniteFile create(String url, NtlmPasswordAuthentication auth) throws IOException {
    try {//from ww  w  . j a  v a2s  .  c om
        if (url.startsWith("s3://")) {
            return new AwsInfiniteFile(url, auth);
        } else if (url.startsWith(InternalInfiniteFile.INFINITE_PREFIX)) {
            return new InternalInfiniteFile(url, auth);
        } else {
            return new InfiniteFile(url, auth);
        }
    } catch (SmbException e) {
        throw new IOException(e.getMessage(), e);
    }

}