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.navercorp.client.Main.java

public static void printResult(Result r) {
    try {/*from  w  w  w.  j av  a  2s .  c  o m*/
        System.out.println(mapper.writeValueAsString(r));
    } catch (IOException e) {
        e.printStackTrace(System.err);
        System.err.println(e.getMessage());
        System.exit(INTERNAL_ERROR.n());
    }
}

From source file:jp.xet.baseunits.tests.SerializationTester.java

/**
 * ????????/*  www  .  j a  va  2  s  . c  om*/
 * 
 * @param serializable 
 * @throws AssertionError ????
 */
public static void assertCanBeSerialized(Object serializable) {
    if (Serializable.class.isInstance(serializable) == false) {
        fail("Object doesn't implement java.io.Serializable interface: " + serializable.getClass());
    }

    ObjectOutputStream out = null;
    ObjectInputStream in = null;
    ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
    ByteArrayInputStream byteArrayIn = null;
    try {
        out = new ObjectOutputStream(byteArrayOut);
        out.writeObject(serializable);

        byteArrayIn = new ByteArrayInputStream(byteArrayOut.toByteArray());
        in = new ObjectInputStream(byteArrayIn);
        Object deserialized = in.readObject();
        if (serializable.equals(deserialized) == false) {
            fail("Reconstituted object is expected to be equal to serialized");
        }
    } catch (IOException e) {
        fail(e.getMessage());
    } catch (ClassNotFoundException e) {
        fail(e.getMessage());
    } finally {
        IOUtils.closeQuietly(out);
        IOUtils.closeQuietly(in);
    }
}

From source file:com.sagalasan.eveapi.engine.RequestEngine.java

public static byte[] xmlRequest(XmlRequest xmlRequest) {
    try {/*from   w  w w.  jav  a2 s  .c  o  m*/
        URL url = new URL(xmlRequest.buildUri());
        URLConnection connection = url.openConnection();
        InputStream inputStream = connection.getInputStream();
        return IOUtils.toByteArray(inputStream);
    } catch (IOException e) {
        logger.error(e.getMessage());
    }

    return null;
}

From source file:Main.java

public static String readInternalFileContent(Context content, String fileName) {
    String file = new String(), tmp;
    try {//from  ww  w  .  ja  va  2s.co m
        // Read the file
        BufferedReader bf = new BufferedReader(new InputStreamReader(content.openFileInput(fileName)));
        while ((tmp = bf.readLine()) != null) {
            file += tmp;
        }
        bf.close();
    } catch (IOException e) {
        Log.e("JSO reading", "Error reading the file " + fileName + "\n" + e.getMessage());
    }
    return file;
}

From source file:com.handany.base.generator.FreemarkerUtil.java

public static Template getTemplate(String templateName) {
    try {/*  ww w.  ja  v  a2 s  . c o  m*/
        Version version = new Version(2, 3, 23);
        Configuration cfg = new Configuration(version);
        File file = new File("src/main/java/com/handany/base/generator/template");
        System.out.println(file.getAbsolutePath());
        FileTemplateLoader fileTemplateLoader = new FileTemplateLoader(file);
        cfg.setTemplateLoader(fileTemplateLoader);
        cfg.setObjectWrapper(new DefaultObjectWrapper(version));
        cfg.setDefaultEncoding(CHARSET);
        return cfg.getTemplate(templateName);
    } catch (IOException ex) {
        log.error(ex.getMessage(), ex);
        throw new RuntimeException(ex);
    }
}

From source file:net.sourceforge.mavenhippo.gen.FreemarkerUtils.java

public static Template getTemplate(String path, Class<?> classLoaderOfClass) {
    try {//from   ww w  .j  a  va  2s. co  m
        Template result;
        Configuration configuration = new Configuration();
        ClassTemplateLoader templateLoader = new ClassTemplateLoader(classLoaderOfClass, "/");
        configuration.setTemplateLoader(templateLoader);
        result = configuration.getTemplate(path);
        return result;
    } catch (IOException e) {
        throw new FreemarkerUtilsExceptoin(e.getMessage(), e);
    }
}

From source file:Main.java

public static String getMac() {
    String result = "";
    try {// w  w w  .  j a va 2 s.  c o m

        Process process = Runtime.getRuntime().exec("ipconfig /all");

        InputStreamReader ir = new InputStreamReader(process.getInputStream());

        LineNumberReader input = new LineNumberReader(ir);

        String line;

        while ((line = input.readLine()) != null)

            if (line.indexOf("Physical Address") > 0) {

                String MACAddr = line.substring(line.indexOf("-") - 2);

                result = MACAddr;

            }

    } catch (java.io.IOException e) {

        System.err.println("IOException " + e.getMessage());

    }
    return result;
}

From source file:Main.java

/**
 * Create file if !exist//from w w w  .  ja va 2 s  .c  o  m
 * 
 * @param filePath
 *            The absolute file path we need to create
 * 
 * @throws IOException
 *             Input/Output exceptions
 */
public static void createFile(File filePath) {
    if (!filePath.exists()) {
        try {
            filePath.createNewFile();
            Log.d("RDWR", "createFile: " + filePath);
        } catch (IOException e) {
            e.printStackTrace();
            Log.d("RDWR", "CreateFile: " + e.getMessage());
        }
    }
}

From source file:org.apache.streams.converter.TypeConverterUtil.java

public static Object convert(Object object, Class outClass, ObjectMapper mapper) {
    ObjectNode node = null;//from w  w  w. j  a v  a2s  . co m
    Object outDoc = null;
    if (object instanceof String) {
        try {
            node = mapper.readValue((String) object, ObjectNode.class);
        } catch (IOException e) {
            LOGGER.warn(e.getMessage());
            LOGGER.warn(object.toString());
        }
    } else {
        node = mapper.convertValue(object, ObjectNode.class);
    }

    if (node != null) {
        try {
            if (outClass == String.class)
                outDoc = mapper.writeValueAsString(node);
            else
                outDoc = mapper.convertValue(node, outClass);

        } catch (Throwable e) {
            LOGGER.warn(e.getMessage());
            LOGGER.warn(node.toString());
        }
    }

    return outDoc;
}

From source file:com.confighub.api.common.Files.java

/**
 * Read local file from resources folder with a path relative to the test.
 *
 * @param testClass/*from   w ww  . java  2s  .  co m*/
 * @param file
 * @return String content of the file
 */
public static String readLocalFile(Class testClass, String file) {
    try {
        return IOUtils.toString(testClass.getResourceAsStream(file), "UTF-8");
    } catch (IOException e) {
        fail(e.getMessage());
        return "";
    }
}