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

private boolean FS_PeakClusterRead() {
    if (!new File(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName)
            + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS").exists()) {
        return false;
    }/*from   w w w .  j  a  va  2s. co  m*/
    try {
        Logger.getRootLogger().info("Reading PeakCluster serialization from file:"
                + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS...");

        FileInputStream fileIn = new FileInputStream(
                FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName)
                        + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS");
        FSTObjectInput in = new FSTObjectInput(fileIn);
        PeakClusters = (ArrayList<PeakCluster>) in.readObject();
        in.close();
        fileIn.close();
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
        if (FS_PeakClusterRead_Old()) {
            WritePeakClusterSerialization();
            return true;
        }
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
        return false;
    }
    return true;
}

From source file:edu.ku.brc.helpers.XMLHelper.java

/**
 * Reads in a file of HTML, primarily from the Help directory and fixes up the images
 * to have an absolute path. Plus it strip everything before and including the 'body' tag and
 * strips the '</body>' to the end.
 * @param file the html file to be read.
 * @return the file as a string/*  w ww .  ja  v  a2  s  .com*/
 */
@SuppressWarnings("deprecation") //$NON-NLS-1$
public static String fixUpHTML(final File file) {
    String path = FilenameUtils.getFullPath(file.getAbsolutePath());

    StringBuilder sb = new StringBuilder();
    try {
        List<?> lines = FileUtils.readLines(file);
        boolean fndBegin = false;

        for (Object lineObj : lines) {
            String line = (String) lineObj;
            if (!fndBegin) {
                if (line.indexOf("<body") > -1) //$NON-NLS-1$
                {
                    fndBegin = true;
                }
                continue;
            }
            int inx = line.indexOf("<img"); //$NON-NLS-1$
            if (inx > -1) {
                inx = line.indexOf("src=\"", inx); //$NON-NLS-1$

                sb.append(line.substring(0, inx + 5));
                File f = new File(path);
                sb.append(f.toURL()); // needed for 1.5
                sb.append(line.substring(inx + 5, line.length()));
            } else {
                sb.append(line + "\n"); //$NON-NLS-1$
            }
        }
    } catch (IOException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(XMLHelper.class, ex);
        log.error(ex);
    }
    return sb.toString();
}

From source file:MSUmpire.DIA.DIAPack.java

public void GenerateClusterScanNomapping() throws IOException {
    if (!new File(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename)
            + ".ScanClusterMapping_Q1").exists()) {
        String mgfname1 = FilenameUtils.getFullPath(Filename) + GetQ1Name() + ".mgf";
        String mgfname2 = FilenameUtils.getFullPath(Filename) + GetQ2Name() + ".mgf";
        String mgfname4 = FilenameUtils.getFullPath(Filename) + GetQ3Name() + ".mgf";

        BufferedReader reader1 = new BufferedReader(new FileReader(mgfname1));
        BufferedReader reader2 = new BufferedReader(new FileReader(mgfname2));
        BufferedReader reader4 = new BufferedReader(new FileReader(mgfname4));

        FileWriter writer = new FileWriter(FilenameUtils.getFullPath(Filename)
                + FilenameUtils.getBaseName(Filename) + ".ScanClusterMapping_Q1");
        FileWriter writer2 = new FileWriter(FilenameUtils.getFullPath(Filename)
                + FilenameUtils.getBaseName(Filename) + ".ScanClusterMapping_Q2");
        FileWriter writer4 = new FileWriter(FilenameUtils.getFullPath(Filename)
                + FilenameUtils.getBaseName(Filename) + ".ScanClusterMapping_Q3");

        BufferedReader mzReader = new BufferedReader(
                new FileReader(FilenameUtils.getFullPath(Filename) + GetQ1Name() + ".mzXML"));
        String line = "";
        int ScanNo = 0;
        while ((line = mzReader.readLine()) != null) {
            if (line.contains("<scan num=")) {
                String substr = line.substring(line.indexOf("<scan num=") + 11);
                ScanNo = Integer.parseInt(substr.substring(0, substr.indexOf("\"")));
                break;
            }//from   w w  w. j  av  a  2 s.c  o m
        }
        while ((line = reader1.readLine()) != null) {
            if (line.startsWith("TITLE=")) {
                int ClusterIndex = Integer.parseInt(line.split("ClusterIndex:")[1].split(",")[0]);
                writer.write(ScanNo + "_" + ClusterIndex + "\n");
                ScanNo++;
            }
        }
        mzReader = new BufferedReader(
                new FileReader(FilenameUtils.getFullPath(Filename) + GetQ2Name() + ".mzXML"));
        line = "";
        ScanNo = 0;
        while ((line = mzReader.readLine()) != null) {
            if (line.contains("<scan num=")) {
                String substr = line.substring(line.indexOf("<scan num=") + 11);
                ScanNo = Integer.parseInt(substr.substring(0, substr.indexOf("\"")));
                break;
            }
        }
        while ((line = reader2.readLine()) != null) {
            if (line.startsWith("TITLE=")) {
                int ClusterIndex = Integer.parseInt(line.split("ClusterIndex:")[1].split(",")[0]);
                writer2.write(ScanNo + "_" + ClusterIndex + "\n");
                ScanNo++;
            }
        }

        mzReader = new BufferedReader(
                new FileReader(FilenameUtils.getFullPath(Filename) + GetQ3Name() + ".mzXML"));
        line = "";
        ScanNo = 0;
        while ((line = mzReader.readLine()) != null) {
            if (line.contains("<scan num=")) {
                String substr = line.substring(line.indexOf("<scan num=") + 11);
                ScanNo = Integer.parseInt(substr.substring(0, substr.indexOf("\"")));
                break;
            }
        }
        while ((line = reader4.readLine()) != null) {
            if (line.startsWith("TITLE=")) {
                int ClusterIndex = Integer.parseInt(line.split("ClusterIndex:")[1].split(",")[0]);
                String DIAwindow = line.split("TITLE=")[1].split(";")[0];
                writer4.write(ScanNo + ";" + DIAwindow + ";" + ClusterIndex + "\n");
                ScanNo++;
            }
        }
        writer.close();
        writer2.close();
        writer4.close();
        reader1.close();
        reader2.close();
        mzReader.close();
        reader4.close();
    }
    ReadScanNoMapping();
}

From source file:MSUmpire.LCMSPeakStructure.LCMSPeakMS1.java

public String GetIPROPHETPepXML() {
    return FilenameUtils.getFullPath(ParentmzXMLName) + "interact-" + FilenameUtils.getBaseName(ParentmzXMLName)
            + ".iproph.pep.xml";
}

From source file:MSUmpire.LCMSPeakStructure.LCMSPeakMS1.java

public String GetIPROPHETProtXML() {
    return FilenameUtils.getFullPath(ParentmzXMLName) + "interact-" + FilenameUtils.getBaseName(ParentmzXMLName)
            + ".iproph.prot.xml";
}

From source file:edu.cornell.med.icb.goby.modes.ReformatCompactReadsMode.java

/**
 * Get the filename including path WITHOUT fastx extensions (including .gz if it is there).
 *
 * @param name the full path to the file in question
 * @return the filename without the fastx/gz extensions or the same name of those extensions
 *         weren't found./*from www  .j  a  v  a 2s. co  m*/
 */
private static String stripCompactReadExtensions(final String name) {
    final String filename = FilenameUtils.getName(name);
    for (final String ext : FileExtensionHelper.COMPACT_READS_FILE_EXTS) {
        if (filename.endsWith(ext)) {
            return FilenameUtils.getFullPath(name) + filename.substring(0, filename.lastIndexOf(ext));
        }
    }
    return name;
}

From source file:MSUmpire.LCMSPeakStructure.LCMSPeakBase.java

private boolean FS_PeakClusterRead_Old() {
    if (!new File(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName)
            + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS").exists()) {
        return false;
    }/*from www . j a v  a2 s .c  om*/
    try {
        Logger.getRootLogger().info("Old PeakCluster serialization from file:"
                + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS...");

        FileInputStream fileIn = new FileInputStream(
                FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName)
                        + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS");
        org.nustaq_old.serialization.FSTObjectInput in = new org.nustaq_old.serialization.FSTObjectInput(
                fileIn);
        PeakClusters = (ArrayList<PeakCluster>) in.readObject();
        in.close();
        fileIn.close();
    } catch (Exception ex) {
        Logger.getRootLogger().error("Old version reader still failed.");
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
        return false;
    }
    return true;
}

From source file:MSUmpire.LCMSPeakStructure.LCMSPeakMS1.java

public void ParsePepXML(DBSearchParam param, float prob) throws ParserConfigurationException, IOException,
        SAXException, XmlPullParserException, ClassNotFoundException, InterruptedException {
    IDsummary = new LCMSID(
            FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName),
            param.DecoyPrefix, param.FastaPath);
    PepXMLParser pepxmlparser = new PepXMLParser(IDsummary, param.InteractPepXMLPath, prob);
    CheckPSMRT();/*from  ww w . java  2s  . com*/
}

From source file:it.drwolf.ridire.index.cwb.scripts.VRTFilesBuilder.java

private void processResourcesOfJob(Integer jobId, VRTFilesBuilderData vrtFilesBuilderData)
        throws SystemException, NotSupportedException, SecurityException, IllegalStateException,
        RollbackException, HeuristicMixedException, HeuristicRollbackException {
    File destDir = new File(vrtFilesBuilderData.getDestDir());
    if (!this.userTx.isActive()) {
        this.userTx.begin();
    }/*from  w  w  w  .j a v  a  2 s  .com*/
    this.entityManager.joinTransaction();
    Long totResources = (Long) this.entityManager.createQuery(
            "select count (cr.id) from CrawledResource cr where cr.deleted is false and cr.job.id=:jobId and cr.wordsNumber>0")
            .setParameter("jobId", jobId).getSingleResult();
    this.entityManager.flush();
    this.entityManager.clear();
    this.userTx.commit();
    StrTokenizer strTokenizer = new StrTokenizer("\t");
    for (int k = 0; k < totResources; k += VRTFilesBuilder.MAXRESULTS) {
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        List<CrawledResource> crawledResources = this.entityManager.createQuery(
                "from CrawledResource cr where cr.deleted is false and cr.job.id=:jobId and cr.wordsNumber>0 order by cr.id")
                .setParameter("jobId", jobId).setFirstResult(k).setMaxResults(VRTFilesBuilder.MAXRESULTS)
                .getResultList();
        for (CrawledResource cr : crawledResources) {
            String posFileName = FilenameUtils.getFullPath(cr.getArcFile()) + JobMapperMonitor.RESOURCESDIR
                    + cr.getDigest() + ".txt.pos";
            this.createVRTFile(posFileName, strTokenizer, cr, destDir);
        }
        this.entityManager.flush();
        this.entityManager.clear();
        this.userTx.commit();
        System.out.println("VRT - Processing resources " + k + " of " + totResources);
    }
}

From source file:com.haulmont.cuba.security.app.UserManagementServiceBean.java

private String getLocalizedTemplateContent(String defaultTemplateName, String locale) {
    String localizedTemplate = FilenameUtils.getFullPath(defaultTemplateName)
            + FilenameUtils.getBaseName(defaultTemplateName) + "_" + locale + "."
            + FilenameUtils.getExtension(defaultTemplateName);

    return resources.getResourceAsString(localizedTemplate);
}