Example usage for java.io IOException getClass

List of usage examples for java.io IOException getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:net.decix.jatlasx.csv.CsvReader.java

public List<String> getColumn(String rowIdentifier) {

    CSVParser parser = null;// w w  w  . j a va 2s  . c  o m
    List<String> column = new ArrayList<String>();

    try {
        parser = new CSVParser(new FileReader(fileName), csvFileFormat);

        if (parser != null) {
            for (CSVRecord record : parser) {
                column.add(record.get(rowIdentifier).toString());
            }
        }

        parser.close();
    } catch (IOException e) {
        String errorMsg = "Could not read File:" + fileName;
        System.err.println(e.getClass().getName() + ":" + errorMsg + " (" + this.getClass().getName() + ")");
    }
    return column;
}

From source file:FileViewer.java

/**
 * Load and display the specified file from the specified directory
 *//*from   w w  w  .ja v  a2 s .c  o  m*/
public void setFile(String directory, String filename) {
    if ((filename == null) || (filename.length() == 0))
        return;
    File f;
    FileReader in = null;
    // Read and display the file contents. Since we're reading text, we
    // use a FileReader instead of a FileInputStream.
    try {
        f = new File(directory, filename); // Create a file object
        in = new FileReader(f); // And a char stream to read it
        char[] buffer = new char[4096]; // Read 4K characters at a time
        int len; // How many chars read each time
        textarea.setText(""); // Clear the text area
        while ((len = in.read(buffer)) != -1) { // Read a batch of chars
            String s = new String(buffer, 0, len); // Convert to a string
            textarea.append(s); // And display them
        }
        this.setTitle("FileViewer: " + filename); // Set the window title
        textarea.setCaretPosition(0); // Go to start of file
    }
    // Display messages if something goes wrong
    catch (IOException e) {
        textarea.setText(e.getClass().getName() + ": " + e.getMessage());
        this.setTitle("FileViewer: " + filename + ": I/O Exception");
    }
    // Always be sure to close the input stream!
    finally {
        try {
            if (in != null)
                in.close();
        } catch (IOException e) {
        }
    }
}

From source file:io.sprucehill.mandrill.service.AbstractService.java

<T, E extends Error> T send(final AbstractPayload payload, TypeReference<T> responseClass, Class<E> errorClass)
        throws E, IOException {
    try {//from   w ww.ja v  a2 s.  c o  m
        HttpPost request = new HttpPost(baseUrl + payload.getPath());
        String body = objectMapper.writeValueAsString(payload);
        logger.info(body);
        request.setEntity(new StringEntity(body, "UTF-8"));
        HttpResponse response = httpClient.execute(request);
        if (200 == response.getStatusLine().getStatusCode()) {
            T result = objectMapper.readValue(response.getEntity().getContent(), responseClass);
            return result;
        } else {
            E error = objectMapper.readValue(response.getEntity().getContent(), errorClass);
            logger.debug("Got error {} while calling {}.", error.toString(), payload.getPath());
            throw error;
        }
    } catch (IOException e) {
        logger.debug("Got {} while calling {}.", e.getClass().getSimpleName(), payload.getPath());
        throw e;
    }
}

From source file:com.urbancode.x2o.xml.NamespaceConfiguration.java

public void loadNameSpaceFromClassPath(String nameSpace) {
    BidiMap biMap = new DualHashBidiMap();
    String filePath = nameSpace.replaceAll("\\.", Matcher.quoteReplacement("/"));
    String resourceName = filePath + "/" + NAMESPACE_FILE;
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    Properties props = new Properties();

    log.debug("Looking for resource: " + resourceName);

    try {/*  w  w w .  j av a 2  s  .  c  o  m*/
        props.load(classLoader.getResourceAsStream(resourceName));
    } catch (IOException e) {
        log.error(e.getClass() + " caught in " + this.getClass());
        // swallow
    }

    // build the biDirectionalMap
    for (Object prop : props.keySet()) {
        biMap.put(prop, props.getProperty((String) prop));
    }

    log.debug("added following elements into map: " + biMap.keySet());
    log.debug("Added following value: " + biMap.values());

    nameSpaces.put(nameSpace, biMap);
}

From source file:de.kaiserpfalzEdv.office.core.license.impl.LicenseServiceImpl.java

private void dumpKeyDigest() {
    if (LOG.isDebugEnabled()) {
        try {/*from   www .  j  a va2  s  . c  om*/
            License license = new License();
            license.loadKeyRingFromResource(KEY_RING, null);
            LOG.info("Keyring digest is: {}", license.dumpPublicKeyRingDigest());
        } catch (IOException e1) {
            LOG.error(e1.getClass().getSimpleName() + " caught: " + e1.getMessage(), e1);
        }
    }
}

From source file:org.paxle.parser.tika.impl.ParserContentHandler.java

@Override
public void endDocument() throws SAXException {
    super.endDocument();
    try {/* w  w  w.  java 2  s .  com*/
        this.parserDocWriter.flush();
    } catch (IOException e) {
        this.logger.error(
                String.format("Unexpected %s while parsing %s.", e.getClass().getName(), this.baseLocation), e);
    }
}

From source file:co.bugjar.android.monitor.BugjarMonitor.java

/**
 * Submit any saved stack traces//from w  w  w  .  jav a  2 s. co  m
 * @param context
 */
private void submitStackTraces(Context context) {
    final DefaultHttpClient httpClient = new DefaultHttpClient();

    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    final String widthPixels = String.valueOf(metrics.widthPixels);
    final String heightPixels = String.valueOf(metrics.heightPixels);

    Runnable submitter = new Runnable() {

        @Override
        public void run() {
            HttpPost request = new HttpPost(BJ_SERVER);

            request.addHeader("version", BM_VERSION);
            request.addHeader("versionName", versionName);
            request.addHeader("versionCode", versionCode);
            request.addHeader("apiKey", apiKey);
            request.addHeader("widthPixels", widthPixels);
            request.addHeader("heightPixels", heightPixels);

            try {
                File d = new File(filesDir);
                File[] stackTraces = d.listFiles(new ExceptionHandler.StackTraceFilter());
                if (stackTraces != null && stackTraces.length > 0) {
                    for (int i = 0; i < stackTraces.length; i++) {
                        File f = stackTraces[i];

                        Log.d(TAG, "sending " + f.getAbsolutePath());
                        request.setEntity(new InputStreamEntity(new FileInputStream(f), f.length()));

                        HttpResponse response = httpClient.execute(request);
                        if (response.getStatusLine().getStatusCode() == 200) {
                            f.delete();
                        } else {
                            Log.w(TAG, "Bugjar server returned " + response.getStatusLine().toString());
                        }
                    }
                } else {
                    // say hello
                    HttpResponse response = httpClient.execute(request);
                    Log.d(TAG, response.getStatusLine().toString());
                }
            } catch (IOException e) {
                Log.e(TAG, e.getClass().getSimpleName() + " caught submitting stack trace: " + e.getMessage());
            }
        }
    };

    new Thread(submitter).start();
}

From source file:net.ladenthin.snowman.imager.run.uploader.Uploader.java

private void logIOExceptionAndWait(IOException e) {
    LOGGER.warn("Known IOException: {} (maybe no network, wait a little bit)", e.getClass());
    Imager.waitALittleBit(5000);//from w  ww .  j a v a  2  s .c o m
}

From source file:com.veterinaria.jsf.controllers.RegistroPersonaController.java

public void registrarCliente() {
    try {// ww w  .j  av  a2  s.  c  om
        clienteActual.setPassword(DigestUtils.sha1Hex(password));
        clienteActual.setFechaCreacionCliente(new Date());
        clienteActual.setEstado(true);
        getClienteFacade().create(clienteActual);
        addSuccesMessage("Registrado", "Registro Exitoso.");
        recargarLista();
        FacesContext.getCurrentInstance().getExternalContext().redirect("registroPag.xhtml");
    } catch (IOException e) {
        addErrorMessage("Error closing resource " + e.getClass().getName(), "Message: " + e.getMessage());

    }

}

From source file:com.liferay.ci.portlet.TravisIntegrationPortlet.java

protected void buildProjectsStack(RenderRequest request) {
    PortletPreferences portletPreferences = request.getPreferences();

    String jobNamesParam = portletPreferences.getValue("jobnames", StringPool.BLANK);

    AuthConnectionParams connectionParams = getConnectionParams();

    try {/*  w ww.  j av  a2s  . com*/
        ContinuousIntegrationJob[] jobs = parseJobNames(jobNamesParam);

        ContinuousIntegrationJob[] lastBuilds = JSONBuildUtil.getLastBuilds(connectionParams, jobs);

        request.setAttribute(TravisIntegrationConstants.TRAVIS_JOBS, lastBuilds);
    } catch (IOException ioe) {
        SessionErrors.add(request, ioe.getClass());

        _log.error("The jobs were not available", ioe);
    } catch (JSONException e) {
        _log.error("The jobs are not well-formed", e);
    }
}