Example usage for java.io IOException toString

List of usage examples for java.io IOException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:edu.snu.dolphin.dnn.data.NeuralNetworkDataParser.java

/** {@inheritDoc} */
@Override//w ww  .  j  ava 2 s. c o m
public void parse() {
    final List<Pair<Pair<Matrix, int[]>, Boolean>> dataList = new ArrayList<>();
    final BatchGenerator trainingBatchGenerator = new BatchGenerator(dataList, false);
    final BatchGenerator validationBatchGenerator = new BatchGenerator(dataList, true);

    for (final Pair<LongWritable, Text> keyValue : dataSet) {
        final String text = keyValue.getSecond().toString().trim();
        if (text.startsWith("#") || 0 == text.length()) {
            continue;
        }
        try {
            final Matrix input = readNumpy(matrixFactory, new ByteArrayInputStream(text.getBytes()), delimiter);
            final Matrix data = input.get(range(0, input.getRows() - 2));
            final int label = (int) input.get(input.getRows() - 2);
            final boolean isValidation = ((int) input.get(input.getRows() - 1) == 1);

            if (isValidation) {
                validationBatchGenerator.push(data, label);
            } else {
                trainingBatchGenerator.push(data, label);
            }
        } catch (final IOException e) {
            parseException = new ParseException("IOException: " + e.toString());
            return;
        }
    }

    trainingBatchGenerator.cleanUp();
    validationBatchGenerator.cleanUp();

    result = dataList;
}

From source file:jp.terasoluna.fw.web.struts.taglib.ChangeStyleClassTag.java

/**
 * ^O]Jn?\bh?B/*from w  w  w  .  j a v  a 2s .  c  o  m*/
 * G?[L?oX^CV?[gNX?X?B
 *
 * @return ???w
 * @throws JspException JSPO
 */
@Override
public int doStartTag() throws JspException {
    HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
    if (req == null) {
        return SKIP_BODY;
    }
    String result = chooseClass(req, this.name, this.defaultValue, this.errorValue);
    try {
        JspWriter out = pageContext.getOut();
        out.print(result);
    } catch (IOException e) {
        log.error("Output failed.");
        throw new JspTagException(e.toString());
    }
    return EVAL_BODY_INCLUDE;
}

From source file:eu.vital.vitalcep.cep.CepProcess.java

public void freeBSR() {

    try {/* w w w .ja va 2  s  .  co m*/
        logger.debug("MIGULE, bytes disponibles en stdin del cep: " + bsr.available());
        bsr.reset();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        logger.debug(e.toString());
    }

}

From source file:com.panet.imeta.trans.steps.accessoutput.AccessOutput.java

public void dispose(StepMetaInterface smi, StepDataInterface sdi) {
    meta = (AccessOutputMeta) smi;//from  ww  w  . j  av a2  s  .  c  o m
    data = (AccessOutputData) sdi;
    if (data.oneFileOpened) {
        try {
            // Put the last records in the table as well!
            if (data.table != null) {
                data.table.addRows(data.rows);
            }

            // Just for good measure.
            data.rows.clear();

            if (data.db != null)
                data.db.close();
        } catch (IOException e) {
            logError("Error closing the database: " + e.toString());
            setErrors(1);
            stopAll();
        }
    }
    super.dispose(smi, sdi);
}

From source file:org.openmrs.module.dhisreport.web.controller.Dhis2ServerController.java

public boolean testConnection(URL url, String username, String password, HttpDhis2Server server,
        WebRequest webRequest, ModelMap model) {
    String host = url.getHost();/*from w w  w .ja v a  2  s  .c  o m*/
    int port = url.getPort();

    HttpHost targetHost = new HttpHost(host, port, url.getProtocol());
    DefaultHttpClient httpclient = new DefaultHttpClient();
    BasicHttpContext localcontext = new BasicHttpContext();

    try {
        HttpGet httpGet = new HttpGet(url.getPath()); // +
        // DATAVALUESET_PATH
        // );
        httpGet.addHeader(
                BasicScheme.authenticate(new UsernamePasswordCredentials(username, password), "UTF-8", false));

        HttpResponse response = httpclient.execute(targetHost, httpGet, localcontext);

        //System.out.println( "Http Response :" + response + ":" + response.getStatusLine().getStatusCode() );

        if (response.getStatusLine().getStatusCode() == 200) {
            log.debug("Dhis2 server configured: " + username + ":xxxxxx  " + url.toExternalForm());
            return true;
        }

        else {
            log.debug("Dhis2 server not configured");
            return false;
        }
    } catch (IOException ex) {
        log.debug("Problem accessing DHIS2 server: " + ex.toString());
        return false;
    } finally {
        httpclient.getConnectionManager().shutdown();
    }
}

From source file:Good_GUi.java

private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel3MouseClicked
    box += "Processing...\n";
    jTextArea1.setText(box);//from  w  w w  .j a v a 2  s  . c  o  m
    String url = jTextField1.getText();
    HttpClient httpClient = new DefaultHttpClient();
    try {
        URIBuilder uriBuilder = new URIBuilder("https://eastus2.api.cognitive.microsoft.com/vision/v1.0/ocr");

        uriBuilder.setParameter("language", "unk");
        uriBuilder.setParameter("detectOrientation ", "true");

        URI uri = uriBuilder.build();
        HttpPost request = new HttpPost(uri);

        // Request headers - replace this example key with your valid subscription key.
        request.setHeader("Content-Type", "application/json");
        request.setHeader("Ocp-Apim-Subscription-Key", "43a031e5db9f438aac7c50a7df692016");
        // Request body. Replace the example URL with the URL of a JPEG image containing text.
        StringEntity requestEntity = new StringEntity("{\"url\":\"" + jTextField1.getText() + "\"}");
        request.setEntity(requestEntity);
        HttpResponse response = httpClient.execute(request);
        HttpEntity entity = response.getEntity();
        String s = EntityUtils.toString(entity);
        ArrayList<String> list = new ArrayList<>();
        if (s.contains("Invalid")) {
            box += "Can't fetch the image @ " + url + "\n";
            jTextArea1.setText(box);

        } else {
            System.out.println(s);
            String[] splitted = s.split("}");
            for (String c : splitted) {
                list.add(c.substring(c.lastIndexOf(":") + 2).replaceAll("\"", ""));
            }
            String out = "";
            for (int i = 0; i < list.size(); i++) {
                out += list.get(i) + " ";
            }
            out.replaceAll("  ", " ");
            String x = "";
            for (int i = 0; i < out.length(); i++) {
                x += out.substring(i, i + 1);

            }
            try {
                PrintWriter writer = new PrintWriter("ITT.txt", "UTF-8");
                writer.println(x);
                writer.close();
                box += "Success! File saved as ITT.txt\n";
                jTextArea1.setText(box);

                ProcessBuilder pb = new ProcessBuilder("Notepad.exe", "ITT.txt");
                pb.start();
            } catch (IOException e) {
                box += e.toString();
                jTextArea1.setText(box);
            }

            Parser p = new Parser(x);
            p.parse();
            StringSelection stringSelection = new StringSelection(p.toString());
            java.awt.datatransfer.Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
            clpbrd.setContents(stringSelection, null);
            JOptionPane.showMessageDialog(null, "Github data copied to clipboard!");
        }
    } catch (Exception e) {
        box += e.toString() + "\n";
        jTextField1.setText(box);

    }

}

From source file:aes.pica.touresbalon.tb_serviciosbolivariano.ServiciosBolivarianos.java

@Override
public List<TouresBalonOrdenVO> consultaReservas(String ordenId) {
    List<TouresBalonOrdenVO> listaReservasTB = new ArrayList<>();
    String nombreArchivo = Constantes.NAME_RESERVAS + ordenId + Constantes.CSV_FILE;
    try {// ww w .  ja v a2  s.  co m
        File archivoConsulta = FileUtils.getFile(rutaReservas, nombreArchivo);
        if (archivoConsulta != null && archivoConsulta.exists()) {
            List<String> lineasArchivo = FileUtils.readLines(archivoConsulta);
            System.out.println("Archivo encontrado: " + archivoConsulta.getAbsoluteFile());
            for (String s : lineasArchivo) {
                listaReservasTB.add(new TouresBalonOrdenVO(s));
            }
        } else {
            System.out.println("No existe archivo: " + nombreArchivo + " en el directorio: " + rutaReservas);
        }
    } catch (IOException ex) {
        System.err.println(ex.toString());
    }
    return listaReservasTB;
}

From source file:gov.nih.nci.ncicb.tcga.dcc.bamloader.LoaderBAM.java

protected boolean readTextFile() {
    boolean validTextFile = true;
    String bamFile = (BAMLoaderConstants.isExtendedBAMFile()) ? BAMLoaderConstants.extendedBAMFilePath
            : BAMLoaderConstants.BAMFilePath;
    logger.info("Reading File " + BAMLoaderConstants.BAMFilePath + " ....");

    BufferedReader bufferedReader = null;
    try {/*from   ww w. j a v  a2s .com*/
        bufferedReader = new BufferedReader(new FileReader(bamFile));
        String line;
        int rowCount = 0;
        final Date dccReceivedDate = new Date();
        while ((line = bufferedReader.readLine()) != null) {
            rowCount++;
            // ignore the first line
            if (line.contains("barcode")) {
                continue;
            }

            try {
                String[] rowData = line.split("\t");
                final BAMFile bf = getBamFileBean(rowData);
                bf.setDccDateReceived(dccReceivedDate);
                fileBAMs.add(bf);
            } catch (Exception e) {
                logger.error(" Row " + rowCount + " contains invalid data " + e.getMessage(), e);
                validTextFile = false;
            }
        }
        logger.info("Total number of Rows: " + fileBAMs.size());

    } catch (IOException ioe) {
        logger.error(ioe.toString());
        validTextFile = false;
    }
    return validTextFile;
}

From source file:org.powertac.server.ServerPropertiesService.java

private boolean validXmlResource(Resource xml) {
    log.debug("resource class: " + xml.getClass().getName());
    try {/*from w w  w.  j ava  2s .  co m*/
        String path = xml.getURI().toString();
        for (String regex : excludedPaths) {
            if (path.matches(regex)) {
                log.debug("invalid path " + path);
                return false;
            }
        }
        return true;
    } catch (IOException e) {
        log.error("Should not happen: " + e.toString());
        return false;
    }
}

From source file:com.ec2box.manage.socket.SecureShellWS.java

@OnMessage
public void onMessage(String message) {

    if (session.isOpen() && StringUtils.isNotEmpty(message)) {

        Map jsonRoot = new Gson().fromJson(message, Map.class);

        String command = (String) jsonRoot.get("command");

        Integer keyCode = null;//  ww  w. j a  v  a 2s  .  co  m
        Double keyCodeDbl = (Double) jsonRoot.get("keyCode");
        if (keyCodeDbl != null) {
            keyCode = keyCodeDbl.intValue();
        }

        for (String idStr : (ArrayList<String>) jsonRoot.get("id")) {
            Integer id = Integer.parseInt(idStr);

            //get servletRequest.getSession() for user
            UserSchSessions userSchSessions = SecureShellAction.getUserSchSessionMap().get(sessionId);
            if (userSchSessions != null) {
                SchSession schSession = userSchSessions.getSchSessionMap().get(id);
                if (keyCode != null) {
                    if (keyMap.containsKey(keyCode)) {
                        try {
                            schSession.getCommander().write(keyMap.get(keyCode));
                        } catch (IOException ex) {
                            log.error(ex.toString(), ex);
                        }
                    }
                } else {
                    schSession.getCommander().print(command);
                }
            }

        }
        //update timeout
        AuthUtil.setTimeout(httpSession);
    }

}