Example usage for java.io IOException getMessage

List of usage examples for java.io IOException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.sg2net.utilities.ListaCAP.json.JsonUtilties.java

public static Collection<Comune> deserializeFrom(File file) {
    if (file == null) {
        throw new IllegalArgumentException("File is null");
    }/* w w w.  j  av  a  2  s.c o  m*/
    if (!file.exists() || file.isDirectory() || !file.canRead()) {
        throw new IllegalArgumentException("File " + file.getName() + " is not file or is not readable ");
    }
    try {
        return JSONMapper.readValue(file, new TypeReference<List<Comune>>() {
        });
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:de.xwic.appkit.core.util.StreamUtil.java

/**
 * @param closable//  w  w w . j a  v a2 s . com
 * @param log
 */
public static void close(final Log log, final Closeable... closables) {
    for (final Closeable closable : closables) {
        if (null == closable) {
            continue;
        }
        try {
            closable.close();
        } catch (final IOException e) {
            log.error(e.getMessage(), e);
        }
    }
}

From source file:Main.java

private static String readInStream(FileInputStream inStream) {
    try {/*from  www  . ja  v  a2 s.  co  m*/
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        byte[] buffer = new byte[512];
        int length = -1;
        while ((length = inStream.read(buffer)) != -1) {
            outStream.write(buffer, 0, length);
        }

        outStream.close();
        inStream.close();
        return outStream.toString();
    } catch (IOException e) {
        Log.i("FileTest", e.getMessage());
    }
    return null;
}

From source file:hu.petabyte.redflags.engine.RedflagsEngineApp.java

private static void exportConfig(String fn) {
    try {//from  w  w  w. j av a 2 s. c om
        StreamUtils.copyToString(new ClassPathResource("application.yml").getInputStream(),
                Charset.forName("UTF-8"));
        System.out.println("Internal application.yml copied out to " + fn);
    } catch (IOException e) {
        System.out.println("Operation failed: " + e.getMessage());
    }
}

From source file:m.omarh.liferay.resources.importer.generator.util.JSONUtil.java

public static void writeJSONObjectToFile(String jsonObjectFileTarget, String sitemapJsonObjectString) {

    try {/*from  w w w. j  ava  2  s.  co  m*/
        FileUtil.write(jsonObjectFileTarget, sitemapJsonObjectString);
    } catch (IOException e) {
        _log.error(e.getMessage());
    }
}

From source file:m.omarh.liferay.resources.importer.generator.util.JSONUtil.java

public static void writeJSONObjectToFile(String jsonObjectFileTarget, byte[] bytes) {

    try {//from   ww w.j  ava  2  s. c o  m
        FileUtil.write(jsonObjectFileTarget, bytes);
    } catch (IOException e) {
        _log.error(e.getMessage());
    }
}

From source file:cn.vlabs.clb.api.io.FileUtil.java

public static void copy(String from, String to) {
    FileInputStream in = null;//from w  ww .  j  ava2s. c om
    FileOutputStream out = null;
    try {
        in = new FileInputStream(from);
        out = new FileOutputStream(to);
        copy(in, out);
    } catch (IOException e) {
        LOG.error(e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(in);
        IOUtils.closeQuietly(out);
    }
}

From source file:Main.java

public static void closingFailed(IOException e) {
    throw new RuntimeException(e.getMessage());
}

From source file:com.alibaba.flink.utils.MetricsMonitor.java

public static Map httpResponse(String url) {
    Map ret;//from w w w.j  a  v a2  s .  c om
    try {
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpGet getRequest = new HttpGet(url);
        getRequest.addHeader("accept", "application/json");

        HttpResponse response = httpClient.execute(getRequest);

        if (response.getStatusLine().getStatusCode() != 200) {
            throw new RuntimeException(
                    "Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
        }

        String data = EntityUtils.toString(response.getEntity());

        ret = (Map) Utils.from_json(data);

        httpClient.getConnectionManager().shutdown();

    } catch (IOException e) {
        ret = errorMsg(e.getMessage());
    }
    return ret;
}

From source file:Main.java

public static String readFromInternalStorage(Context context, String fileName) {

    File file = new File(context.getFilesDir(), fileName);

    try {//from   w w  w.  j  a va  2 s.  c om
        FileInputStream fis = new FileInputStream(file);
        DataInputStream in = new DataInputStream(fis);
        BufferedReader br = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
        String line;

        StringBuilder stringBuilder = new StringBuilder();
        while ((line = br.readLine()) != null) {
            stringBuilder.append(line);
        }
        String json = stringBuilder.toString();

        br.close();
        in.close();
        fis.close();

        return json;
    } catch (IOException e) {
        Log.e(TAG, e.getMessage(), e);
    }

    return null;
}