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.example.admin.processingboilerplate.JsonIO.java

public static StringBuilder load(HttpURLConnection con) {
    StringBuilder sb = new StringBuilder();
    BufferedReader br = null;/*from  w  w w  . j  a  va2 s .  c  o  m*/
    try {
        br = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
        String s;
        while ((s = br.readLine()) != null)
            sb.append(s).append('\n');
    } catch (IOException e) {
        Log.e("loadJson", e.getMessage(), e);
    } finally {
        try {
            if (br != null)
                br.close();
            con.disconnect();
        } catch (IOException e) {
            Log.e("loadJson", e.getMessage(), e);
        }
    }
    return sb;
}

From source file:eu.optimis.sm.gui.utils.ConfigManager.java

private static void createDefaultConfigFile(File fileObject) throws Exception {

    new File(fileObject.getParent()).mkdirs();
    new File(fileObject.getAbsolutePath()).delete();
    new File(fileObject.getAbsolutePath()).createNewFile();

    log.debug("Copying file " + fileObject.getName());
    InputStream streamIn = ConfigManager.class.getResourceAsStream("/" + fileObject.getName());
    FileOutputStream streamOut = new FileOutputStream(fileObject.getAbsolutePath());
    byte[] buf = new byte[8192];
    while (true) {
        int length = streamIn.read(buf);
        if (length < 0) {
            break;
        }/*w  w w .  ja va 2 s. c  o  m*/
        streamOut.write(buf, 0, length);
    }

    try {
        streamIn.close();
    } catch (IOException ex) {
        log.error("Couldn't close input stream");
        log.error(ex.getMessage());
    }
    try {
        streamOut.close();
    } catch (IOException ex) {
        log.error("Couldn't close file output stream");
        log.error(ex.getMessage());
    }
}

From source file:Main.java

/**
 * Reads the argument XML input String.// w w w  .ja v a  2 s. c o  m
 * @param xmlString The XML input String to be parsed.
 * @return The root node of the read DOM document.
 */
public static Node readXML(String xmlString) {
    try {
        DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = builderFactory.newDocumentBuilder();

        Document doc = builder.parse(new InputSource(new StringReader(xmlString)));
        return doc.getDocumentElement();
    } catch (SAXException saxEx) {
        throw new IllegalArgumentException("readXML() Caught SAXException: ", saxEx);
    } catch (IOException ioEx) {
        throw new IllegalArgumentException("readXML() Caught IOException: " + ioEx.getMessage(), ioEx);
    } catch (ParserConfigurationException parsEx) {
        throw new IllegalArgumentException("readXML() Caught ParserConfigurationException: ", parsEx);
    } // try - catch
}

From source file:com.cjwagner.InfoSecPriv.ExtensionServer.java

private static void updateLogFile(String ip, LoggerMessage data) {
    File file = new File(logDir + "/" + ip + logFileExt);
    try {/* w  ww  .j a  v a2 s . c  om*/
        FileUtils.writeStringToFile(file, LoggerMessage.toJSON(data), null);
    } catch (IOException e) {
        System.out.println("Failed to create file: " + file.getName() + "  ERROR: " + e.getMessage());
    }
}

From source file:com.ajah.http.Http.java

/**
 * Calls {@link #get(URI)} but returns null instead of throwing exceptions.
 * //from  w  ww.  j  av  a 2  s.c o  m
 * @param uri
 *            The URL to fetch.
 * @return The response as a String, or null.
 */
public static String getSafe(final String uri) {
    try {
        return get(uri);
    } catch (final IOException e) {
        log.log(Level.WARNING, e.getMessage(), e);
        return null;
    } catch (final HttpException e) {
        log.log(Level.WARNING, e.getMessage(), e);
        return null;
    }
}

From source file:io.alicorn.device.client.DeviceClient.java

private static String apacheHttpEntityToString(HttpEntity entity) {
    try {/* ww  w .j  a  va  2s.co  m*/
        if (entity != null) {
            String encoding = "UTF-8";
            if (entity.getContentEncoding() != null) {
                encoding = entity.getContentEncoding().getValue();
                encoding = encoding == null ? "UTF-8" : encoding;
            }
            return EntityUtils.toString(entity, encoding);
        } else {
            logger.error("Cannot parse a null ApacheHttpEntity.");
        }
    } catch (IOException e) {
        logger.error("Unexpected IO error when parsing entity content [" + e.getMessage() + "].", e);
    }

    return "";
}

From source file:org.edgexfoundry.EdgeXConfigWatcherApplication.java

private static boolean loadProperties() {
    Properties properties = new Properties();
    try (final InputStream inputStream = new FileInputStream(APP_PROPERTIES)) {
        properties.load(inputStream);/*from w w w . j a va 2 s  .c o  m*/
        serviceName = properties.getProperty("service.name");
        globalPrefix = properties.getProperty("global.prefix");
        servicePrefix = properties.getProperty("service.prefix");
        consulProtocol = properties.getProperty("consul.protocol");
        consulHost = properties.getProperty("consul.host");
        consulPort = Integer.parseInt(properties.getProperty("consul.port", "8500"));
        notificationPathKey = properties.getProperty("notification.path.key");
        notificationProtocol = properties.getProperty("notification.protocol");
        if (serviceName == null || globalPrefix == null || servicePrefix == null || consulProtocol == null
                || consulHost == null || consulPort == 0 || notificationPathKey == null
                || notificationProtocol == null) {
            LOGGER.error(
                    "Application configuration did not load properly or is missing elements.  Cannot create watcher.");
            System.exit(1);
            return false;
        }
    } catch (IOException ex) {
        LOGGER.error("IO Exception getting application properties: " + ex.getMessage());
        System.exit(1);
        return false;
    }
    return true;
}

From source file:org.envirocar.app.network.HTTPClient.java

/**
 * Convenience method to consume the contents of an entity.
 * //from   w ww. j  a v a  2 s  .com
 * @param entity content-holding entity
 */
public static void consumeEntity(HttpEntity entity) {
    try {
        if (entity == null || entity.getContent() == null)
            return;
        entity.consumeContent();
    } catch (IOException e) {
        logger.warn(e.getMessage());
    }
}

From source file:CFDI_Verification.CFDI_Verification.java

public static void list_directories(String directory) {
    String server = "192.1.1.64";
    String user = "ftpuser";
    String pass = "Oracle123";
    String result = "No Connected!";

    FTPClient ftpClient = new FTPClient();

    try {//from ww  w .  j a va  2 s .c o  m
        ftpClient.connect(server);
        ftpClient.login(user, pass);
        ftpClient.enterLocalPassiveMode();
        ftpClient.changeWorkingDirectory(directory);

        String[] directories = ftpClient.listNames();
        String dir;

        for (int i = 0; i < directories.length; i++) {
            System.out.println(directories[i]);
            dir = directories[i];
        }

        ftpClient.logout();
        ftpClient.disconnect();

    } catch (IOException ex) {
        System.out.println("Ooops! Error en conexin." + ex.getMessage());
    }
}

From source file:CFDI_Verification.CFDI_Verification.java

public static ARRAY getDirectories(String directory) throws SQLException {
    Connection conn = new OracleDriver().defaultConnection();
    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("DIRECTORIES_LIST", conn);

    String server = "192.1.1.64";
    String user = "ftpuser";
    String pass = "Oracle123";
    String result = "No Connected!";

    FTPClient ftpClient = new FTPClient();

    try {//from  ww w. j a  v  a 2 s. co m
        ftpClient.connect(server);
        ftpClient.login(user, pass);
        ftpClient.enterLocalPassiveMode();
        ftpClient.changeWorkingDirectory(directory);

        String[] directories = ftpClient.listNames();
        ARRAY directories_list = new ARRAY(descriptor, conn, directories);

        ftpClient.logout();
        ftpClient.disconnect();

        return directories_list;
    } catch (IOException ex) {
        System.out.println("Ooops! Error en conexin." + ex.getMessage());
    }
    return null;
}