Example usage for org.apache.commons.io FilenameUtils getFullPath

List of usage examples for org.apache.commons.io FilenameUtils getFullPath

Introduction

In this page you can find the example usage for org.apache.commons.io FilenameUtils getFullPath.

Prototype

public static String getFullPath(String filename) 

Source Link

Document

Gets the full path from a full filename, which is the prefix + path.

Usage

From source file:MSUmpire.LCMSPeakStructure.LCMSPeakBase.java

public void ExportPeakClusterResultCSV() throws IOException {

    Logger.getRootLogger().info("Writing PeakCluster CSV:" + FilenameUtils.getFullPath(ScanCollectionName)
            + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.csv...");
    FileWriter writer = new FileWriter(FilenameUtils.getFullPath(ScanCollectionName)
            + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.csv");

    String mzstring = "";
    String Idxstring = "";
    String CorrString = "";
    String SNRString = "";
    String PeakheightString = "";
    String PeakheightRTString = "";
    String PeakAreaString = "";
    String IdentifiedString = "0";

    for (int i = 0; i < MaxNoPeakCluster; i++) {
        mzstring += ",mz" + (i + 1);
        Idxstring += ",PeakIdx" + (i + 1);
        if (i > 0) {
            CorrString += ",Corr" + (i + 1);
        }/*from w w  w  . j a  v a 2  s .com*/
        SNRString += ",SNR" + (i + 1);
        PeakheightString += ",PeakHeight" + (i + 1);
        PeakheightRTString += ",PeakHeightRT" + (i + 1);
        PeakAreaString += ",PeakArea" + (i + 1);
    }

    writer.write("Cluster_Index,StartRT,EndRT,StartScan,EndScan,Identified,Charge" + mzstring + Idxstring
            + CorrString + SNRString + PeakheightString + PeakheightRTString + PeakAreaString
            + ",IsoMapProb,ConflictCorr,LeftInt,RightInt,NoRidges,MS1Score,MS1Prob,MS1LProb\n");

    for (PeakCluster cluster : PeakClusters) {
        IdentifiedString = "0";
        if (cluster.Identified) {
            IdentifiedString = "1";
        }

        String statementString = cluster.Index + "," + cluster.startRT + "," + cluster.endRT + ","
                + cluster.StartScan + "," + cluster.EndScan + "," + IdentifiedString + "," + cluster.Charge
                + ",";

        mzstring = "";
        Idxstring = "";
        CorrString = "";
        SNRString = "";
        PeakheightString = "";
        PeakheightRTString = "";
        PeakAreaString = "";

        for (int i = 0; i < MaxNoPeakCluster; i++) {
            mzstring += cluster.mz[i] + ",";
            Idxstring += cluster.IsoPeakIndex[i] + ",";
            if (i > 0) {
                CorrString += cluster.Corrs[i - 1] + ",";
            }
            SNRString += cluster.GetSNR(i) + ",";
            PeakheightString += cluster.PeakHeight[i] + ",";
            PeakheightRTString += cluster.PeakHeightRT[i] + ",";
            PeakAreaString += cluster.PeakArea[i] + ",";
        }
        statementString += mzstring + Idxstring + CorrString + SNRString + PeakheightString + PeakheightRTString
                + PeakAreaString + cluster.IsoMapProb + "," + cluster.GetConflictCorr() + "," + cluster.LeftInt
                + "," + cluster.RightInt + "," + cluster.NoRidges + "," + cluster.MS1Score + ","
                + cluster.MS1ScoreProbability + "," + cluster.MS1ScoreLocalProb + "\n";
        writer.write(statementString);
    }
    writer.close();
    //System.out.print("Finished multithreading\n");
}

From source file:egovframework.rte.fdl.excel.impl.EgovExcelServiceImpl.java

public HSSFWorkbook createWorkbook(HSSFWorkbook wb, String filepath)
        throws BaseException, FileNotFoundException, IOException {

    String fullFileName = filepath;

    log.debug(//from w  ww .ja  va 2 s.  c  om
            "EgovExcelServiceImpl.createWorkbook : templatePath is " + FilenameUtils.getFullPath(fullFileName));

    //   ?
    if (!EgovFileUtil.isExistsFile(FilenameUtils.getFullPath(fullFileName))) {
        log.debug("make dir " + FilenameUtils.getFullPath(fullFileName));

        try {
            FileUtils.forceMkdir(new File(FilenameUtils.getFullPath(fullFileName)));
        } catch (IOException e) {
            throw new IOException(
                    "Cannot create directory for path: " + FilenameUtils.getFullPath(fullFileName));
        }
    }

    FileOutputStream fileOut = new FileOutputStream(fullFileName);

    log.debug("EgovExcelServiceImpl.createWorkbook : templatePath is " + fullFileName);

    try {
        log.debug("ExcelServiceImpl loadExcelObject ...");

        wb.write(fileOut);

    } catch (Exception e) {
        log.error(getMessageSource().getMessage("error.excel.runtime.error", new Object[] { "createWorkbook" },
                Locale.getDefault()), e);
    } finally {
        log.debug("ExcelServiceImpl loadExcelObject end...");
        fileOut.close();
    }

    return wb;
}

From source file:info.fetter.logstashforwarder.FileWatcher.java

private void addSingleFile(String fileToWatch, Event fields, int deadTime) throws Exception {
    logger.info("Watching file : " + new File(fileToWatch).getCanonicalPath());
    String directory = FilenameUtils.getFullPath(fileToWatch);
    String fileName = FilenameUtils.getName(fileToWatch);
    IOFileFilter fileFilter = FileFilterUtils.and(FileFilterUtils.fileFileFilter(),
            FileFilterUtils.nameFileFilter(fileName), new LastModifiedFileFilter(deadTime));
    initializeWatchMap(new File(directory), fileFilter, fields);
}

From source file:it.grid.storm.info.SpaceInfoManager.java

/**
 * Populate with DU tasks/* w  w w.  j a  v  a  2  s  .  com*/
 */
private void fakeSAtoAnalyze(List<String> absPaths) {

    // Create a list of SSD using the list of AbsPaths
    List<StorageSpaceData> toAnalyze = new ArrayList<StorageSpaceData>();
    for (String path : absPaths) {
        path = path + File.separator;
        String pathNorm = FilenameUtils.normalize(FilenameUtils.getFullPath(path));
        StorageSpaceData ssd = new StorageSpaceData();
        try {
            PFN spaceFN = PFN.make(pathNorm);
            log.trace("PFN : ", spaceFN);
            ssd.setSpaceToken(TSpaceToken.make(new it.grid.storm.common.GUID().toString()));

            ssd.setSpaceFileName(spaceFN);
            toAnalyze.add(ssd);
        } catch (InvalidTSpaceTokenAttributesException e) {
            log.error("Unable to create Space Token. {}", e.getMessage(), e);
        } catch (InvalidPFNAttributeException e) {
            log.error("Unable to create PFN. {}", e.getMessage(), e);
        }
    }

    for (StorageSpaceData ssd : toAnalyze) {
        TSpaceToken sT = ssd.getSpaceToken();
        String absPath = ssd.getSpaceFileNameString();
        try {
            bDUTasks.addTask(sT, absPath);
            log.debug("Added {} to the DU-Task Queue. (Task queue size: {})", absPath, bDUTasks.howManyTask());
        } catch (SAInfoException e) {
            log.error(e.getMessage(), e);
        }
    }
    log.info("Background DU tasks size: {}", bDUTasks.getTasks().size());
}

From source file:edu.scripps.fl.pubchem.xmltool.gui.PubChemXMLCreatorGUI.java

public void mouseClicked(MouseEvent e) {
    try {/*from w w  w. jav a2 s . c  o  m*/
        if (e.getClickCount() > 0) {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            if (e.getSource() == jtpExample) {
                URL url = getClass().getClassLoader().getResource("ExampleExcel.xlsx");
                File tmpFile = File.createTempFile("example", ".xlsx");
                FileUtils.copyURLToFile(url, tmpFile);
                tmpFile.deleteOnExit();
                Desktop.getDesktop().open(tmpFile);
            } else if (e.getSource() == jtpExcelTemplate) {
                File saveFile = gc.fileChooser(jtfFileExcel, ".xlsx", "save");
                if (saveFile != null) {
                    URL url = getClass().getClassLoader().getResource("ExcelTemplate_withBAO.xlsx");
                    OutputStream out = new FileOutputStream(saveFile, true);
                    IOUtils.copy(url.openStream(), out);
                    String output = FilenameUtils.concat(FilenameUtils.getFullPath(saveFile.toString()),
                            FilenameUtils.getBaseName(saveFile.toString()));
                    Desktop.getDesktop().open(new File(saveFile.toString()));
                }
            } else if (e.getSource() == jtfFileTemplate && jtfFileTemplate.getText().equals(template)) {
                jtfFileTemplate.setText("");
            } else if (e.getSource() == this) {
                if (jtfFileTemplate.getText().equals("")) {
                    jtfFileTemplate.setText(template);
                }
            }
        }
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    } catch (Throwable throwable) {
        SwingGUI.handleError(this, throwable);
    }
}

From source file:info.fetter.logstashforwarder.FileWatcher.java

private void addWildCardFiles(String filesToWatch, Event fields, int deadTime) throws Exception {
    logger.info("Watching wildcard files : " + filesToWatch);
    String directory = FilenameUtils.getFullPath(filesToWatch);
    String wildcard = FilenameUtils.getName(filesToWatch);
    logger.trace("Directory : " + new File(directory).getCanonicalPath() + ", wildcard : " + wildcard);
    IOFileFilter fileFilter = FileFilterUtils.and(FileFilterUtils.fileFileFilter(),
            new WildcardFileFilter(wildcard), new LastModifiedFileFilter(deadTime));
    initializeWatchMap(new File(directory), fileFilter, fields);
}

From source file:it.drwolf.ridire.session.async.IndexMerger.java

private void transferFile(String www1localstore, String jobName, CrawledResource cr)
        throws JSchException, SftpException, IOException {
    int mode = ChannelSftp.OVERWRITE;
    String localDir = www1localstore + System.getProperty("file.separator") + jobName;
    FileUtils.forceMkdir(new File(localDir));
    this.c.get(/*  w  ww.j  a  v  a  2 s.com*/
            FilenameUtils.getFullPath(cr.getArcFile()) + System.getProperty("file.separator") + "resources"
                    + System.getProperty("file.separator") + cr.getDigest() + ".txt.pos",
            localDir + System.getProperty("file.separator") + cr.getDigest() + ".txt.pos", null, mode);
}

From source file:com.jaspersoft.studio.server.editor.ReportRunControler.java

public void runReport() {
    final VSimpleErrorPreview errorView = pcontainer.getErrorView();
    pcontainer.getRightContainer().switchView(null, errorView);
    errorView.setMessage(com.jaspersoft.studio.messages.Messages.ReportControler_generating);

    c = pcontainer.getConsole();/*from  w ww  . j a v a 2s  .co  m*/
    c.showConsole();
    c.clearConsole();
    pcontainer.setJasperPrint(null, null);

    stats = new Statistics();
    stats.startCount(ReportControler.ST_REPORTEXECUTIONTIME);
    c.addMessage(Messages.ReportRunControler_statsstart);

    pcontainer.setNotRunning(false);

    Job job = new Job(com.jaspersoft.studio.messages.Messages.PreviewEditor_preview_a + ": " + reportUnit //$NON-NLS-1$
            + com.jaspersoft.studio.messages.Messages.PreviewEditor_preview_b) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            monitor.beginTask(com.jaspersoft.studio.messages.Messages.ReportRunControler_3,
                    IProgressMonitor.UNKNOWN);
            try {
                prmInput.setReportUnit(icm, icm.getReportUnit(), monitor, reportUnit);
                if (!prmInput.checkFieldsFilled())
                    return Status.CANCEL_STATUS;
                Map<String, Object> prmcopy = new HashMap<String, Object>();
                for (ResourceDescriptor p : icm.getInputControls()) {
                    if (p.isVisible() && !p.isReadOnly()) {
                        if (p.isMandatory())
                            prmcopy.put(p.getName(), icm.getParameters().get(p.getName()));
                        else if (icm.getParameters().get(p.getName()) != null)
                            prmcopy.put(p.getName(), icm.getParameters().get(p.getName()));
                    }
                }

                List<Argument> args = new ArrayList<Argument>();
                String reptype = pcontainer.getCurrentViewer();
                args.add(new Argument(Argument.RUN_OUTPUT_FORMAT, reptype));
                args.add(new Argument(Argument.RUN_OUTPUT_IMAGES_URI, "")); //$NON-NLS-1$
                repExec.setArgs(args);
                repExec.setStatus("refresh"); //$NON-NLS-1$

                while (repExec.getStatus().equals("refresh") || repExec.getStatus().equals("queued") //$NON-NLS-1$//$NON-NLS-2$
                        || repExec.getStatus().equals("execution")) { //$NON-NLS-1$
                    monitor.setTaskName(repExec.getStatus());
                    repExec = WSClientHelper.runReportUnit(monitor, repExec, prmcopy);
                    if (repExec.getStatus().equals("ready")) { //$NON-NLS-1$
                        stats.endCount(ReportControler.ST_REPORTEXECUTIONTIME);
                        if (repExec.getTotalPages() != null)
                            stats.setValue(ReportControler.ST_PAGECOUNT, repExec.getTotalPages());
                        if (repExec.getReportOutputURL() != null) {
                            showURL(repExec);
                        } else {
                            Map<String, FileContent> files = repExec.getFiles();
                            if (files.isEmpty())
                                showReport(null);
                            for (String key : files.keySet()) {
                                FileContent fc = (FileContent) files.get(key);
                                stats.setValue(ReportControler.ST_REPORTSIZE, fc.getData().length);
                                if (reptype.equals(Argument.RUN_OUTPUT_FORMAT_JRPRINT)) { //$NON-NLS-1$
                                    Object obj = JRLoader.loadObject(new ByteArrayInputStream(fc.getData()));
                                    if (obj instanceof JasperPrint)
                                        showReport((JasperPrint) obj);
                                    break;
                                } else {
                                    // System.out.println(new
                                    // String(fc.getMimeType()));
                                    File f = null;
                                    if (fc.getName().contains("/")) //$NON-NLS-1$
                                        f = new File(FilenameUtils.getFullPath(fc.getName()),
                                                FilenameUtils.getBaseName(fc.getName()));
                                    else
                                        f = new File(tempDir, fc.getName());
                                    if (f == null || !f.exists()) {
                                        f.deleteOnExit();
                                        f.createNewFile();
                                    }
                                    if (!key.equals("report")) { //$NON-NLS-1$
                                        if (!f.getName().equals(key)) {
                                            File dest = new File(tempDir, key);
                                            f.renameTo(dest);
                                            f = dest;
                                        }
                                    } else if (f.getName().endsWith(".att")) { //$NON-NLS-1$
                                        int ind = fc.getMimeType().indexOf("/"); //$NON-NLS-1$
                                        if (ind >= 0) {
                                            String str = fc.getMimeType().substring(ind + 1);
                                            File dest = new File(
                                                    f.getAbsolutePath().replaceAll(".att$", "." + str)); //$NON-NLS-1$ //$NON-NLS-2$
                                            f.renameTo(dest);
                                            f = dest;
                                        }
                                    }
                                    FileOutputStream htmlFile = new FileOutputStream(f);
                                    htmlFile.write(fc.getData());
                                    htmlFile.close();
                                    if (key.equals("report")) //$NON-NLS-1$
                                        showURL(f.toURI().toASCIIString());
                                    // UIUtils.getDisplay().asyncExec(new
                                    // Runnable() {
                                    //
                                    // @Override
                                    // public void run() {
                                    // errorView.setMessage("This file will be opened in an external editor");
                                    // SelectionHelper.openEditor(f);
                                    // }
                                    // });
                                }
                            }
                        }
                    } else if (repExec.getStatus().equals("queued") //$NON-NLS-1$
                            || repExec.getStatus().equals("execution")) { //$NON-NLS-1$
                        showURL(repExec);
                        Thread.sleep(100);
                    } else if (repExec.getStatus().equals("failed") //$NON-NLS-1$
                            || repExec.getStatus().equals("cancelled")) { //$NON-NLS-1$
                        RESTv2ExceptionHandler reh = new RESTv2ExceptionHandler(
                                (ARestV2Connection) WSClientHelper.getClient(monitor,
                                        repExec.getReportURIFull()));
                        throw new Exception(reh.buildMessage(monitor, "", repExec.getErrorDescriptor())); //$NON-NLS-1$
                    }
                    if (monitor.isCanceled()) {
                        WSClientHelper.cancelReportUnit(monitor, repExec);
                        break;
                    }
                }
            } catch (Throwable e) {
                ReportControler.showRunReport(c, pcontainer, e);
            } finally {
                monitor.done();
                finishReport();
            }
            return Status.OK_STATUS;
        }

        private void showReport(final JasperPrint obj) {
            UIUtils.getDisplay().asyncExec(new Runnable() {

                @Override
                public void run() {
                    stats.setValue(ReportControler.ST_PAGECOUNT, obj == null ? 0 : obj.getPages().size());
                    APreview pv = pcontainer.getDefaultViewer();
                    if (pv instanceof IJRPrintable)
                        try {
                            ((IJRPrintable) pv).setJRPRint(stats, obj, true);
                            VBookmarks vs = (VBookmarks) viewmap.get(ReportControler.FORM_BOOKMARKS);
                            vs.setJasperPrint(obj);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    pcontainer.setJasperPrint(stats, obj);
                    pcontainer.setCurrentViewer(pcontainer.getDefaultViewerKey(), true);
                    if (obj == null)
                        errorView.setMessage(com.jaspersoft.studio.messages.Messages.ReportRunControler_22);
                }
            });
        }

        private void showURL(final String url) {
            UIUtils.getDisplay().asyncExec(new Runnable() {

                @Override
                public void run() {
                    APreview pv = pcontainer.getDefaultViewer();
                    if (pv instanceof IURLViewable)
                        try {
                            ((IURLViewable) pv).setURL(url);
                            pcontainer.setCurrentViewer(pcontainer.getDefaultViewerKey(), true);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                }
            });
        }

        private void showURL(final ReportExecution re) {
            if (re.getReportOutputURL() != null) {
                UIUtils.getDisplay().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        APreview pv = pcontainer.getDefaultViewer();
                        if (pv instanceof ABrowserViewer)
                            try {
                                String urlcookie = re.getBaseUrl();
                                String scookie = null;
                                for (Cookie c : re.getReportOutputCookie()) {
                                    if (c.getName().equals("JSESSIONID")) { //$NON-NLS-1$
                                        scookie = c.getName() + "=" + c.getValue(); //$NON-NLS-1$
                                        break;
                                    }
                                }
                                ((ABrowserViewer) pv).setURL(re.getReportOutputURL(), urlcookie, scookie);
                                pcontainer.setCurrentViewer(pcontainer.getDefaultViewerKey(), true);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                    }
                });
            }
        }
    };
    job.setPriority(Job.LONG);
    job.schedule();
}

From source file:MSUmpire.SearchResultParser.TPPResult.java

public void ReadSearchResultByRefIDUseRefProtID(LCMSID lcmsid, ArrayList<String> pepxmls, LCMSID RefID,
        boolean UseMappIon) throws ParserConfigurationException, IOException, SAXException,
        XmlPullParserException, ClassNotFoundException, InterruptedException {
    for (String pepxml : pepxmls) {
        LCMSID pepxmlid = new LCMSID(FilenameUtils.getFullPath(lcmsid.mzXMLFileName)
                + FilenameUtils.getBaseName(lcmsid.mzXMLFileName), DecoyTag, lcmsid.FastaPath);
        PepXMLParser pepxmlparser = new PepXMLParser(pepxmlid, pepxml, 0f);
        pepxmlid.FilterByPepDecoyFDR(DecoyTag, FDR);
        Logger.getRootLogger().info("peptide No.:" + pepxmlid.GetPepIonList().size()
                + "; Peptide level threshold: " + pepxmlid.PepProbThreshold);
        for (PepIonID pepID : pepxmlid.GetPepIonList().values()) {
            lcmsid.AddPeptideID(pepID);//from   w w  w .  j ava  2s  .co  m
        }
    }
    lcmsid.GenerateProteinByRefIDByPepSeq(RefID, UseMappIon);
    lcmsid.LoadSequence();
    lcmsid.ReMapProPep();
    lcmsid.CreateInstanceForAllPepIon();
    Logger.getRootLogger()
            .info("Protein No.:" + lcmsid.ProteinList.size() + "; Assigned Peptide No.:"
                    + lcmsid.AssignedPepIonList.size() + "; All peptide No.:" + lcmsid.GetPepIonList().size()
                    + "; Spectrum level threshold: " + lcmsid.SpecProbThreshold + "; Peptide level threshold: "
                    + lcmsid.PepProbThreshold + "; Protein level threshold: " + lcmsid.ProteinProbThreshold);
}

From source file:it.drwolf.ridire.session.async.Mapper.java

private StringWithEncoding createPlainTextResource(File f, CrawledResource cr, EntityManager entityManager)
        throws SAXException, TikaException, IOException, TransformerConfigurationException,
        InterruptedException {/*from  www  . ja  v a 2s.c  om*/
    File resourceDir = new File(FilenameUtils.getFullPath(f.getCanonicalPath().replaceAll("__\\d+", ""))
            + JobMapperMonitor.RESOURCESDIR);
    String alchemyKey = entityManager.find(Parameter.class, Parameter.ALCHEMY_KEY.getKey()).getValue();
    String readabilityKey = entityManager.find(Parameter.class, Parameter.READABILITY_KEY.getKey()).getValue();
    String resourceFileName = cr.getDigest() + ".gz";
    File resourceFile = new File(resourceDir, resourceFileName);
    StringWithEncoding rawContentAndEncoding = null;
    String contentType = cr.getContentType();
    // long t1 = System.currentTimeMillis();
    if (contentType != null && contentType.contains("application/msword")) {
        rawContentAndEncoding = this.transformDOC2HTML(resourceFile, entityManager);
    }
    if (contentType != null && contentType.contains("application/rtf")) {
        rawContentAndEncoding = this.transformRTF2HTML(resourceFile, entityManager);
    }
    if (contentType != null && contentType.contains("text/plain")) {
        // txt -> html -> txt is for txt cleaning
        rawContentAndEncoding = this.transformTXT2HTML(resourceFile, entityManager);
    }
    if (contentType != null && contentType.contains("pdf")) {
        rawContentAndEncoding = this.transformPDF2HTML(resourceFile, entityManager);
    }
    if (contentType != null && contentType.contains("html")) {
        rawContentAndEncoding = this.getGuessedEncodingAndSetRawContentFromGZFile(resourceFile);
    }
    // long t2 = System.currentTimeMillis();
    // System.out.println("Transformation: " + (t2 - t1));
    if (rawContentAndEncoding != null) {
        if (rawContentAndEncoding.getEncoding() == null) {
            rawContentAndEncoding = new StringWithEncoding(rawContentAndEncoding.getString(), "UTF8");
        }
        // t1 = System.currentTimeMillis();
        String cleanText = this.replaceUnsupportedChars(rawContentAndEncoding.getString());
        rawContentAndEncoding = new StringWithEncoding(cleanText, rawContentAndEncoding.getEncoding());
        File tmpFile = File.createTempFile("ridire", null);
        FileUtils.writeStringToFile(tmpFile, rawContentAndEncoding.getString(), "UTF-8");
        String ridireCleanerJar = entityManager
                .find(CommandParameter.class, CommandParameter.RIDIRE_CLEANER_EXECUTABLE_KEY).getCommandValue();
        String host = entityManager.find(Parameter.class, Parameter.READABILITY_HOSTAPP.getKey()).getValue();
        CommandLine commandLine = CommandLine
                .parse("java -Xmx128m -Djava.io.tmpdir=" + this.tempDir + " -jar " + ridireCleanerJar);
        commandLine.addArgument("-f");
        commandLine.addArgument(tmpFile.getPath());
        commandLine.addArgument("-e");
        commandLine.addArgument("UTF-8");
        commandLine.addArgument("-h");
        commandLine.addArgument(host);
        commandLine.addArgument("-k");
        commandLine.addArgument(alchemyKey);
        commandLine.addArgument("-r");
        commandLine.addArgument(readabilityKey);
        DefaultExecutor executor = new DefaultExecutor();
        executor.setExitValue(0);
        ExecuteWatchdog watchdog = new ExecuteWatchdog(Mapper.READABILITY_TIMEOUT);
        executor.setWatchdog(watchdog);
        ByteArrayOutputStream baosStdOut = new ByteArrayOutputStream(1024);
        ByteArrayOutputStream baosStdErr = new ByteArrayOutputStream(1024);
        ExecuteStreamHandler executeStreamHandler = new PumpStreamHandler(baosStdOut, baosStdErr, null);
        executor.setStreamHandler(executeStreamHandler);
        int exitValue = executor.execute(commandLine);
        if (exitValue == 0) {
            rawContentAndEncoding = new StringWithEncoding(baosStdOut.toString(), "UTF-8");
            // TODO filter real errors
            rawContentAndEncoding.setCleaner(baosStdErr.toString().trim());
        }
        FileUtils.deleteQuietly(tmpFile);
    }
    return rawContentAndEncoding;
}