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(Throwable cause) 

Source Link

Document

Constructs an IOException with the specified cause and a detail message of (cause==null ?

Usage

From source file:org.fusioninventory.utils.EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException {
    FusionInventory.log(EasySSLSocketFactory.class, "Create Easy SSL Context", Log.ERROR);
    try {//from  w w  w.j  a  v  a2 s . com
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new EasyX509TrustManager(null) }, null);
        return context;
    } catch (Exception e) {
        throw new IOException(e.getMessage());
    }
}

From source file:com.webcrawler.manager.impl.StorageManagerImpl.java

@Override
public InputStream downloadImagesFromRemote(String imageURL) throws FileNotFoundException, IOException {
    contentLength = 0;/*  w w  w.  ja v  a  2 s .co m*/
    URL url = new URL(imageURL);
    httpConnection = (HttpURLConnection) url.openConnection();
    int responseCode = httpConnection.getResponseCode();

    if (responseCode == HttpURLConnection.HTTP_OK) {

        inputStream = httpConnection.getInputStream();
        contentLength = httpConnection.getContentLength();

    } else {

        throw new IOException("Error with url " + imageURL + ": " + responseCode);

    }
    return inputStream;
}

From source file:IORoutines.java

public static byte[] load(File file) throws IOException {
    long fileLength = file.length();
    if (fileLength > Integer.MAX_VALUE) {
        throw new IOException("File '" + file.getName() + "' too big");
    }/*from www  .java 2 s .  c  o m*/
    InputStream in = new FileInputStream(file);
    try {
        return loadExact(in, (int) fileLength);
    } finally {
        in.close();
    }
}

From source file:com.qwazr.cluster.manager.ClusterManager.java

public synchronized static Class<? extends ClusterServiceInterface> load(ExecutorService executor,
        String myAddress, Set<String> myGroups) throws IOException {
    if (INSTANCE != null)
        throw new IOException("Already loaded");
    try {// w  ww.ja v a 2s.c om
        INSTANCE = new ClusterManager(executor, myAddress, myGroups);
        if (INSTANCE.isMaster()) {
            // First, we get the node list from another master (if any)
            ClusterManager.INSTANCE.loadNodesFromOtherMaster();
            // All is set, let's start the monitoring
            INSTANCE.clusterMasterThread = (ClusterMasterThread) INSTANCE
                    .addPeriodicThread(new ClusterMasterThread(120));
            INSTANCE.clusterMonitoringThread = (ClusterMonitoringThread) INSTANCE
                    .addPeriodicThread(new ClusterMonitoringThread(60));
        }
        return ClusterServiceImpl.class;
    } catch (URISyntaxException e) {
        throw new IOException(e);
    }
}

From source file:Main.java

public static InputStream openStreamForUri(Context context, Uri uri) throws IOException {
    switch (uri.getScheme()) {
    case ContentResolver.SCHEME_CONTENT:
    case ContentResolver.SCHEME_ANDROID_RESOURCE:
        try {// ww  w.  j a v  a  2s .c  om
            return context.getContentResolver().openInputStream(uri);
        } catch (RuntimeException ignore) {
        }
    case "file":
    case "http":
    case "https":
        return new URL(uri.toString()).openStream();
    }

    throw new IOException("Unable to open " + uri.toString());
}

From source file:com.foundstone.certinstaller.EasySSLSocketFactory.java

private static SSLContext createEasySSLContext(OnCertsRecievedListener listener) throws IOException {
    try {//w w  w . j  av a 2s .  com
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new EasyX509TrustManager(null, listener) }, null);
        return context;
    } catch (Exception e) {
        throw new IOException(e.getMessage());
    }
}

From source file:com.kingmed.dp.ndp.impl.SignInResponseHandler.java

@Override
public String handleResponse(HttpResponse hr) throws ClientProtocolException, IOException {
    String responseBody = null;/*from  ww  w  .ja v  a 2  s.c o m*/
    String connectionStatus = null;
    String cookie = null;
    try {
        responseBody = super.handleResponse(hr);
        connectionStatus = checkStatus(responseBody);
        //??
        if (Strings.isNullOrEmpty(connectionStatus)
                || !connectionStatus.equals(NDPServeImpl.STATUS_SUCCEEDED)) {
            log.error("?");
            throw new IOException("?");
        }
    } catch (Exception e) {
        log.error("?", e);
        throw new IOException(e);
    }
    cookie = getCookie();
    log.info("cookie is [" + cookie + "]");
    return cookie;
}

From source file:com.liferay.jenkins.tools.TestJsonGetter.java

public void linkJsonFile(String file, String url) throws Exception {
    URL fileURL = TestJsonGetter.class.getResource(file);

    if (fileURL == null) {
        throw new IOException(file + " not found");
    }/*from   w ww.  j a va2 s  . c o m*/

    url = formatURL(url);

    logger.info("Linking key {} with resource at {}", url, file);

    testJsons.put(url, file);
}

From source file:com.ibm.stocator.fs.common.Utils.java

/**
 * IOException if the host name is not comply with container.service
 *
 * @param hostname hostname//w  w w  . j  av  a 2  s  .  co m
 * @return IOException
 */
private static IOException badHostName(String hostname) {
    return new IOException(String.format(BAD_HOST, hostname));
}

From source file:Main.java

static public String prepareTmpFilePath(String fileName, String dir) throws IOException {
    File dictionaryRoot = new File(Environment.getExternalStorageDirectory(), dir);
    File dictionaryDirFile = new File(dictionaryRoot, "tmp");
    if (!dictionaryDirFile.exists()) {
        if (!dictionaryDirFile.mkdirs()) {
            throw new IOException("Cannot create directory: " + dictionaryDirFile);
        }// w ww .  j  a  v a 2s.c o  m
    }
    return new File(dictionaryDirFile, fileName + ".mp3").getCanonicalPath();
}