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:com.liferay.mobile.sdk.http.DiscoveryResponseHandler.java

public Discovery handleResponse(HttpResponse response) throws IOException {
    Discovery discovery;/*from  w w w  .j ava2s.c om*/
    String json = EntityUtils.toString(response.getEntity());

    try {
        discovery = new Discovery(json);
    } catch (JSONException je) {
        throw new IOException(je);
    }

    return discovery;
}

From source file:de.hpi.fgis.hdrs.node.Index.java

public static Index openIndex(File indexRoot, Triple.COLLATION order, SegmentIdGenerator idGen)
        throws IOException {
    if (!indexRoot.isDirectory()) {
        throw new IOException("Cannot create index: Index root directory does not exist");
    }/*from   w  w w .j a  va 2 s  . c  o  m*/
    Index index = new Index(indexRoot, order, idGen);
    index.readMeta();
    return index;
}

From source file:com.github.n_i_e.dirtreedb.ApacheCompressCompressorLister.java

public ApacheCompressCompressorLister(PathEntry basepath, InputStream inf) throws IOException {
    super(basepath, inf);
    try {/* w ww  .j  av a  2 s .c  o  m*/
        setInstream(new CompressorStreamFactory().createCompressorInputStream(inf));
    } catch (CompressorException e) {
        throw new IOException(e.toString());
    }
}

From source file:Main.java

/**
 * get all the dex path// w  w  w  . j  a va 2  s.c  o m
 *
 * @param context the application context
 * @return all the dex path
 */
public static List<String> getSourcePaths(Context context)
        throws PackageManager.NameNotFoundException, IOException {
    ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(),
            0);
    File sourceApk = new File(applicationInfo.sourceDir);
    File dexDir = new File(applicationInfo.dataDir, SECONDARY_FOLDER_NAME);

    List<String> sourcePaths = new ArrayList<String>();
    sourcePaths.add(applicationInfo.sourceDir); //add the default apk path

    //the prefix of extracted file, ie: test.classes
    String extractedFilePrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;
    //the total dex numbers
    int totalDexNumber = getMultiDexPreferences(context).getInt(KEY_DEX_NUMBER, 1);

    for (int secondaryNumber = 2; secondaryNumber <= totalDexNumber; secondaryNumber++) {
        //for each dex file, ie: test.classes2.zip, test.classes3.zip...
        String fileName = extractedFilePrefix + secondaryNumber + EXTRACTED_SUFFIX;
        File extractedFile = new File(dexDir, fileName);
        if (extractedFile.isFile()) {
            sourcePaths.add(extractedFile.getAbsolutePath());
            //we ignore the verify zip part
        } else {
            throw new IOException("Missing extracted secondary dex file '" + extractedFile.getPath() + "'");
        }
    }

    return sourcePaths;
}

From source file:org.springdata.ehcache.serializer.DataDeserializer.java

@Override
public T deserialize(InputStream inputStream) throws IOException {

    T obj;//from  w  w w.j a  v  a 2  s.  co m
    try {
        obj = entityClass.newInstance();
    } catch (Exception e) {
        throw new IOException(e);
    }

    DataSerializable io = (DataSerializable) obj;
    io.readFields(new DataInputStream(inputStream));

    return obj;
}

From source file:com.turn.ttorrent.common.Utils.java

/**
 * Resolves a file from URI and returns its byte array.
 * /*from   ww  w.ja  v a 2 s  .  c o  m*/
 * @param uri
 * @return
 * @throws ClientProtocolException
 * @throws IOException
 */
public static byte[] resolveUrlFileToByteArray(URI uri) throws ClientProtocolException, IOException {
    CloseableHttpClient httpclient = HttpClients.createDefault();

    try {

        HttpGet get = new HttpGet(uri);
        HttpResponse response = httpclient.execute(get);
        HttpEntity entity = response.getEntity();

        if (entity != null) {
            InputStream inputStream = entity.getContent();
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            IOUtils.copy(inputStream, outputStream);
            return outputStream.toByteArray();
        }

        throw new IOException("Could not resolve file... [" + uri + "]");

    } finally {
        httpclient.close();
    }

}

From source file:de.flapdoodle.embedmongo.Files.java

public static File createOrCheckUserDir(String prefix) throws IOException {
    File tempDir = new File(System.getProperty("user.home"));
    File tempFile = new File(tempDir, prefix);
    if ((tempFile.exists()) && (tempFile.isDirectory()))
        return tempFile;
    if (!tempFile.mkdir())
        throw new IOException("Could not create Tempdir: " + tempFile);
    return tempFile;
}

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

@Override
public String handleResponse(HttpResponse hr) throws ClientProtocolException, IOException {
    String responseBody = null;// w ww. ja  v  a2  s  .c  om
    String connectionStatus = 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 ex) {
        log.error("", ex);
        throw new IOException(ex);
    }
    return connectionStatus;
}

From source file:mobi.jenkinsci.ci.client.UnsupportedSsoHandler.java

@Override
public IOException getException(final HttpResponse response) {
    return new IOException(unsupportedMessage);
}

From source file:it.geosolutions.geoserver.jms.impl.utils.JMSPropertyPlaceholderConfigurer.java

public JMSPropertyPlaceholderConfigurer(Resource defaultFile, JMSConfiguration config) throws IOException {
    if (!defaultFile.exists()) {
        throw new IOException("Unable to locate the default properties file at:" + defaultFile);
    }/*from   w w w.  j ava  2s  .c om*/
    this.defaults = defaultFile;
    this.config = config;
}