Example usage for java.io IOException getLocalizedMessage

List of usage examples for java.io IOException getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SetTermsListener.java

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".words.tmp");
    try {/*ww w.  j  a v a2  s  .c o  m*/
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write("Filename\tColumn Number\tOriginal Data Value\tNew Data Value\n");
        //  
        HashMap<String, Vector<String>> oldValues = this.setTermsUI.getOldValues();
        HashMap<String, Vector<String>> newValues = this.setTermsUI.getNewValues();

        for (String fullName : oldValues.keySet()) {
            File rawFile = new File(this.dataType.getPath() + File.separator + fullName.split(" - ", -1)[0]);
            String header = fullName.split(" - ", -1)[1];
            int columnNumber = FileHandler.getHeaderNumber(rawFile, header);
            for (int i = 0; i < oldValues.get(fullName).size(); i++) {
                if (newValues.get(fullName).elementAt(i).compareTo("") != 0) {
                    out.write(rawFile.getName() + "\t" + columnNumber + "\t"
                            + oldValues.get(fullName).elementAt(i) + "\t" + newValues.get(fullName).elementAt(i)
                            + "\n");
                }
            }
        }

        out.close();
        try {
            File fileDest;
            if (((ClinicalData) this.dataType).getWMF() != null) {
                String fileName = ((ClinicalData) this.dataType).getWMF().getName();
                ((ClinicalData) this.dataType).getWMF().delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".words");
            }
            FileUtils.moveFile(file, fileDest);
            ((ClinicalData) this.dataType).setWMF(fileDest);
        } catch (IOException ioe) {
            this.setTermsUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setTermsUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setTermsUI.displayMessage("Word mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
    UsedFilesPart.sendFilesChanged(dataType);
}

From source file:com.amazonaws.mturk.cmd.UpdateQualificationType.java

protected void runCommand(CommandLine cmdLine) throws Exception {

    if (!cmdLine.hasOption(ARG_QUALTYPE) && !cmdLine.hasOption(ARG_INPUT_FILE)) {
        log.error("Either -" + ARG_QUALTYPE + " or -" + ARG_INPUT_FILE + " should be passed");
        System.exit(-1);/*from   w ww.j  ava  2  s  .c  o m*/
    }

    String qualId = null;
    if (cmdLine.hasOption(ARG_QUALTYPE)) {
        qualId = cmdLine.getOptionValue(ARG_QUALTYPE);
    } else {
        String qualIds[] = null;
        try {
            qualIds = getFieldValuesFromFile(cmdLine.getOptionValue(ARG_INPUT_FILE), ARG_QUALTYPE);
        } catch (IOException e) {
            log.error("error occured reading file: " + e.getLocalizedMessage(), e);
            System.exit(-1);
        }
        if (qualIds == null || qualIds.length == 0) {
            log.error("qualtypeid must be present in the -" + ARG_INPUT_FILE + " file");
            System.exit(-1);
        }
        qualId = qualIds[0];
    }

    try {
        updateQualificationType(qualId, cmdLine.getOptionValue(ARG_STATUS),
                cmdLine.getOptionValue(ARG_QUESTION), cmdLine.getOptionValue(ARG_ANSWER),
                cmdLine.getOptionValue(ARG_PROPERTIES));
    } catch (Exception e) {
        log.error("Error updating qualification type: " + e.getLocalizedMessage(), e);
        System.exit(-1);
    }
}

From source file:com.wooki.services.parsers.DocumentToXHTML.java

public InputStream performTransformation(Resource xmlDocument) {
    BufferedInputStream in;//  w  ww. jav a  2s.  c  om
    BufferedOutputStream out;
    ByteArrayOutputStream result;
    Tidy tidy = new Tidy();
    java.util.Properties props = new java.util.Properties();

    props.setProperty("new-inline-tags",
            "page-break,page-number,page-numbers,wooki,xsl:value-of,xsl:for-each,quote");
    props.setProperty("new-blocklevel-tags", "for,page-header,page-footer,xsl:value-of,xsl:for-each");
    props.setProperty("new-empty-tags", "page-break,page-number,page-numbers,xsl:value-of");
    // props.setProperty("new-pre-tags", "for,header,footer");
    props.setProperty("new-pre-tags", "wooki");
    tidy.setConfigurationFromProps(props);
    // tidy.setDocType("omit");
    tidy.setXmlOut(xmlOut);
    tidy.setXHTML(true);
    tidy.setEmacs(true);
    tidy.setErrfile("tidyErrors.txt");
    tidy.setFixBackslash(true);
    tidy.setNumEntities(true);
    tidy.setQuoteNbsp(false);
    tidy.setCharEncoding(Configuration.LATIN1);
    // tidy.setInputEncoding("ISO-8859-2");
    tidy.setFixComments(true);
    tidy.setQuoteAmpersand(false);
    tidy.setEncloseText(true);
    tidy.setEncloseBlockText(true);
    // tidy.setWord2000(true);

    try {
        tidy.setErrout(new PrintWriter(new FileWriter("tidyErrors.txt"), true));

        in = new BufferedInputStream(xmlDocument.getInputStream());
        out = new BufferedOutputStream(result = new ByteArrayOutputStream());
        byte[] XMLHeader = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n".getBytes();
        out.write(XMLHeader, 0, XMLHeader.length);

        tidy.parse(in, out);
        out.flush();
        return new ByteArrayInputStream(result.toByteArray());
    } catch (IOException ioe) {
        ioe.printStackTrace();
        logger.error(ioe.getLocalizedMessage());
        return null;
    }
}

From source file:com.martinwunderlich.nlp.arg.aifdb.test.ArgMapTest.java

@org.junit.Test
public void testMapCountsA() {
    List<AIFdbArgumentMap> araucariaList = AIFdbArgumentMapFactory
            .buildArgumentMapListFromNodesetJsonFiles(araucariaPath);
    assertEquals("The number of argument maps in the araucaria list is incorrect", araucariaList.size(), 661);

    try {//from   ww  w.j  a va 2  s . com
        String filePath = "src/test/resources/araucaria/outfile.txt";
        File outFile = new File(filePath);
        if (outFile.exists())
            FileUtils.forceDelete(outFile);
        AIFdbArgumentMapUtil.printNodesToFile(araucariaList, NODE_TYPES.I,
                "src/test/resources/araucaria/outfile.txt");
    } catch (IOException e) {
        fail("Error while trying to write map list to file: " + e.getLocalizedMessage());
    }
}

From source file:com.martinwunderlich.nlp.arg.aifdb.test.ArgMapTest.java

@org.junit.Test
public void testMapCountsS() {
    List<AIFdbArgumentMap> schemesList = AIFdbArgumentMapFactory
            .buildArgumentMapListFromNodesetJsonFiles(schemesPath);
    assertEquals("The number of argument maps in the schemes list is incorrect", schemesList.size(), 31);

    try {/*from www . jav a  2 s  . c o m*/
        String filePath = "src/test/resources/schemes/outfile.txt";
        File outFile = new File(filePath);
        if (outFile.exists())
            FileUtils.forceDelete(outFile);
        AIFdbArgumentMapUtil.printNodesToFile(schemesList, NODE_TYPES.I,
                "src/test/resources/schemes/outfile.txt");
    } catch (IOException e) {
        fail("Error while trying to write map list to file: " + e.getLocalizedMessage());
    }
}

From source file:com.ibm.research.rdf.store.cmd.QueryRdfStore.java

@Override
public void doWork(Connection conn) {

    if (finalArg == null) {
        System.out.println("Query not specified");
        printUsage();//from   w  w w .  jav a  2s.  co  m
        return;
    }

    String query = null;
    // check if this is a file or query String
    File file = new File(finalArg);
    if (file.exists()) {
        StringBuffer queryBuffer = new StringBuffer();
        try {
            BufferedReader br = new BufferedReader(new FileReader(file));
            String line = null;

            while ((line = br.readLine()) != null) {
                queryBuffer.append(line);
            }
            br.close();
        } catch (IOException e) {
            System.out.println(e.getLocalizedMessage());
            printUsage();
            return;
        }
        query = queryBuffer.toString();
    } else {
        query = finalArg;
    }

    try {
        Store store = StoreManager.connectStore(conn, Backend.valueOf(params.get("-backend")),
                params.get("-schema"), storeName, Context.defaultContext);
        String unionDef = params.get("-uniondefaultgraph");
        if (unionDef != null && unionDef.equalsIgnoreCase("true")) {
            store.getContext().set(Context.unionDefaultGraph, true);
        }

        Dataset ds = RdfStoreFactory.connectDataset(store, conn, Backend.valueOf(params.get("-backend")));
        Query q = RdfStoreQueryFactory.create(query);
        QueryExecution qe = RdfStoreQueryExecutionFactory.create(q, ds);

        long rows = 0;
        Model m = null;
        long start = System.currentTimeMillis();

        if (q.isSelectType()) {
            ResultSet rs = qe.execSelect();
            while (rs.hasNext()) {
                QuerySolution qs = rs.next();
                System.out.println(qs);
                System.out.println();
                rows++;
            }
        } else if (q.isDescribeType()) {
            m = qe.execDescribe();
            m.write(System.out, "N-TRIPLE");
        } else if (q.isAskType()) {
            System.out.println(qe.execAsk());

        } else if (q.isConstructType()) {
            m = qe.execConstruct();
            m.write(System.out, "N-TRIPLE");
        }

        long end = System.currentTimeMillis();
        qe.close();
        if (m != null) {
            System.out.println("Number of Rows  : " + m.size());
            m.close();
        } else {
            System.out.println("Number of Rows  : " + rows);
        }
        System.out.println("Time taken      : " + (end - start) + " ms");
    } catch (RdfStoreException e) {
        log.error(e);
        System.out.println(e.getLocalizedMessage());
    } catch (Exception e) {
        log.error(e);
        System.out.println(e.getLocalizedMessage());
    }

}

From source file:be.roots.taconic.pricingguide.service.PricingGuideServiceImpl.java

private void saveRequestForRetry(Request request) {

    String location = requestRetryLocation;

    if (request.getRetryCount() > 5) {
        location = requestErrorLocation;
    }// w  w w .j  av  a 2 s.c o m

    try {
        final String asJson = JsonUtil.asJson(request);

        FileUtils.writeStringToFile(new File(location, UUID.randomUUID().toString() + ".txt"), asJson);
    } catch (IOException e) {
        LOGGER.error(request.getId() + " - " + e.getLocalizedMessage(), e);
    }

}

From source file:org.mashupmedia.controller.configuration.EncodingConfigurationController.java

@RequestMapping(value = PAGE_URL, method = RequestMethod.GET)
public String getEncodingConfiguration(Model model) {
    EncodingPage encodingPage = new EncodingPage();
    String ffMpegFolderPath = encodeManager.getFFMpegFolderPath();
    encodingPage.setFfmpegFolderPath(ffMpegFolderPath);

    String ffMpegFilePath = "";
    File ffMpegFile = encodeManager.findFFMpegExecutable();
    boolean isFfmpegValid = false;
    if (ffMpegFile != null) {
        try {// ww w .  j a  v a2  s  .  c  o m
            if (encodeManager.isValidFfMpeg(ffMpegFile)) {
                ffMpegFilePath = ffMpegFile.getAbsolutePath();
                isFfmpegValid = true;
            }
        } catch (IOException e) {
            encodingPage.setAdditionalErrorMessage(e.getLocalizedMessage());
            logger.error("Error running ffmpeg: " + ffMpegFilePath, e);
        }

    }
    encodingPage.setFfMpegFound(isFfmpegValid);
    configurationManager.saveConfiguration(MashUpMediaConstants.IS_FFMPEG_INSTALLED,
            BooleanUtils.toStringTrueFalse(isFfmpegValid));
    configurationManager.saveConfiguration(MashUpMediaConstants.FFMPEG_PATH, ffMpegFilePath);

    int totalFfmpegProcesses = NumberUtils
            .toInt(configurationManager.getConfigurationValue(ProcessManager.KEY_TOTAL_FFMPEG_PROCESSES));
    encodingPage.setTotalFfmpegProcesses(totalFfmpegProcesses);

    model.addAttribute(encodingPage);
    return PAGE_PATH;
}

From source file:jobhunter.api.infojobs.Client.java

public <T> Optional<T> get(Class<T> clazz, String url) throws InfoJobsAPIException {
    HttpGet httpGet = new HttpGet(url);
    try (CloseableHttpClient client = HttpClients.custom().setDefaultCredentialsProvider(provider).build()) {
        try (CloseableHttpResponse response = client.execute(httpGet)) {
            if (response.getStatusLine().getStatusCode() == 200) {
                T entity = mapper.readValue(response.getEntity().getContent(), clazz);
                return Optional.of(entity);
            } else {
                Error error = mapper.readValue(response.getEntity().getContent(), Error.class);
                throw new InfoJobsAPIException(error);
            }//  w w w. j  av a2 s. c o  m
        }
    } catch (IOException e) {
        l.error("Failed to GET {} from {}", clazz.getCanonicalName(), url, e);
        throw new InfoJobsAPIException(e.getLocalizedMessage());
    }
}

From source file:com.ibm.rpe.web.template.ui.servlet.SaveTemplateLayout.java

@GET
@Path("/savelayout")
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public Response saveTemplateLayout(@Context HttpServletRequest request,
        @QueryParam("layoutjson") String savedJson, @QueryParam("title") String title) {
    try {//from   ww  w.  j  a v  a2s. c  om
        if (title == null) {
            title = UUID.randomUUID().toString() + ".json";
        } else {
            title += ".json";
        }
        return Utils.downloadResponse(IOUtils.toInputStream(savedJson, "UTF-8"), title);
    } catch (IOException e) {
        e.printStackTrace();
        Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getLocalizedMessage()).build();
    }
    return null;
}