Example usage for java.io File separatorChar

List of usage examples for java.io File separatorChar

Introduction

In this page you can find the example usage for java.io File separatorChar.

Prototype

char separatorChar

To view the source code for java.io File separatorChar.

Click Source Link

Document

The system-dependent default name-separator character.

Usage

From source file:de.vandermeer.skb.datatool.commons.DataSet.java

/**
 * Returns the start of a key for key auto-generation
 * @param fs the file name//from  w  w  w.  ja v a2s.  c  o m
 * @param commonPath the common path of all file names
 * @return start of the key
 */
String calcKeyStart(FileSource fs, String commonPath) {
    //remove common path
    String ret = StringUtils.substringAfterLast(fs.getAbsoluteName(), commonPath + File.separator);

    //replace all path separators with key separators
    ret = StringUtils.replaceChars(ret, File.separatorChar, this.cs.getKeySeparator());

    //remove the last dot (".json")
    ret = StringUtils.substringBeforeLast(ret, ".");
    //remove the last dot (".entry") - the entry file extension
    ret = StringUtils.substringBeforeLast(ret, ".");

    //return the key plus a final separator
    return ret + this.cs.getKeySeparator();
}

From source file:info.mikaelsvensson.devtools.sitesearch.PathUtilsTest.java

public void testTwoPaths(final String[] sourcePath, final String[] targetPath) {

    Collection<String> errors = new LinkedList<String>();

    for (int i = 10; i < targetPath.length; i++) {
        String target = StringUtils.join(targetPath, '\\', 0, i + 1);
        for (int j = 10; j < sourcePath.length; j++) {
            String source = StringUtils.join(sourcePath, '\\', 0, j + 1);
            System.out.println(source);
            System.out.println(target);
            File sourceFile = new File(source);
            String relativePath = PathUtils.getRelativePath(sourceFile, new File(target));

            System.out.println(relativePath);
            File sourceFolder = sourceFile.isDirectory() ? sourceFile : sourceFile.getParentFile();

            File actual = new File(sourceFolder, relativePath.replace(PathUtils.SEP, File.separatorChar));
            File expected = new File(target);
            boolean isEqual = actual.toURI().normalize().equals(expected.toURI().normalize());
            if (!isEqual) {
                errors.add("The path from " + source + " to " + target + " is NOT " + actual);
            }/*  w w  w.  j  a v  a2 s .c o  m*/
        }
    }

    assertTrue(errors.toString(), errors.size() == 0);
}

From source file:de.thischwa.pmcms.tool.ChecksumTool.java

/**
 * Converting a set of files to a map. The path of the file is the key of the map and is net of 'pathPrefix'.
 * //w w  w .  j a va 2  s . com
 * @param files
 * @param pathPrefix
 *            has to be an absolute path !!!
 * @param monitor
 * @return Map with files
 */
public static Map<String, String> get(final Collection<File> files, final String pathPrefix,
        final IProgressMonitor monitor) {
    if (StringUtils.isBlank(pathPrefix))
        throw new IllegalArgumentException("Path prefix shouldn't be null!");
    Map<String, String> hashes = new HashMap<String, String>(files.size());
    Fingerprint fingerprint = new Fingerprint();
    for (File file : files) {
        String name = file.getAbsolutePath().toString().substring(pathPrefix.length() + 1)
                .replace(File.separatorChar, '/');
        try {
            hashes.put(name, fingerprint.get(file));
        } catch (Exception e) {
            throw new FatalException("While getting the checksum: " + e.getMessage(), e);
        }
        if (monitor != null)
            monitor.worked(1);
    }
    return hashes;
}

From source file:edu.du.penrose.systems.fedoraApp.batchIngest.data.BatchIngestXMLhandlerImpl.java

/**
 * Set the class variable xmlFileIterator based on files contained in a local directory.
 * /* w  w w. ja  va  2s .  c om*/
 * @param fileURL
 * @throws FatalException 
 */
private void setFileXMLiterator(URL fileURL) {

    String metsDirectoryName = fileURL.getFile().replace('/', File.separatorChar);

    metsDirectory = new FileComparator(metsDirectoryName);

    xmlFileIterator = Arrays.asList(metsDirectory.listFiles(this.myFileFilter)).iterator();

}

From source file:ie.pars.bnc.preprocess.MainBNCProcess.java

private static void getZippedFile() throws IOException, ArchiveException, Exception {
    String taggerPath = "edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger";
    String parseModel = LexicalizedParser.DEFAULT_PARSER_LOC;

    InputStream is = new FileInputStream(pathInput);
    TarArchiveInputStream tarStream = (TarArchiveInputStream) new ArchiveStreamFactory()
            .createArchiveInputStream("tar", is);
    TarArchiveEntry entry = null;/*from w  w w . j a  v a2s  .co  m*/
    int countfiles = 0;
    while ((entry = (TarArchiveEntry) tarStream.getNextEntry()) != null) {
        //     for(File lf: listFiles){ 
        if (!entry.isDirectory()) {

            byte[] content = new byte[(int) entry.getSize()];
            int offset = 0;
            tarStream.read(content, offset, content.length - offset);
            String id = entry.getName().split("/")[entry.getName().split("/").length - 1].split(".xml")[0];

            if (!filesProcesed.contains(id) && id.startsWith(letter.toUpperCase())) {
                if (countfiles++ % 10 == 0) {
                    tagger = new MaxentTagger(taggerPath);
                    m = new Morphology();
                    parser = ParserGrammar.loadModel(parseModel);
                    parser.loadTagger();
                }
                System.out.print("Entry " + entry.getName());

                InputStream bis = new ByteArrayInputStream(content);
                StringBuilder parseBNCXML = ProcessNLP.parseBNCXML(bis, m, tagger, parser);
                bis.close();
                OutputStream out = new FileOutputStream(pathOutput + File.separatorChar + id + ".vert");
                Writer writer = new OutputStreamWriter(out, "UTF-8");

                writer.write("<text id=\"" + id + "\">\n");
                writer.write(parseBNCXML.toString());
                writer.write("</text>\n");
                writer.close();
                out.close();
            } else {
                System.out.println(">> Bypass Entry " + entry.getName());
            }
            //break;
        }

    }
    is.close();
    System.out.println("There are " + countfiles);
    //    tarStream.close();

}

From source file:edu.stanford.muse.datacache.BlobStore.java

/**
 * @param dir directory where this store keeps its data
 *///from   ww w. j  a v a2s.c  om
public BlobStore(String dir) throws IOException {
    log.info("Opening file repository in " + dir);
    this.dir = dir;
    File dir_file = new File(dir);
    if (!dir_file.exists())
        dir_file.mkdirs();
    else {
        // could also lock the dir to make sure no other data store object uses this dir inadvertently
        File f = new File(this.dir + File.separatorChar + META_DATA_FILENAME);
        if (f.exists()) {
            unpack();
            log.info("File repository in " + dir + " has " + uniqueBlobs.size() + " entries");
        }
    }
}

From source file:net.ontopia.infoset.fulltext.impl.lucene.LuceneFulltextImplementation.java

@Override
public synchronized void install(TopicMapReferenceIF reference) {
    this.reference = reference;
    if (reference instanceof AbstractOntopolyURLReference) {
        AbstractOntopolyURLReference ref = (AbstractOntopolyURLReference) reference;

        String indexDirectory = ref.getIndexDirectory();
        if ((indexDirectory == null) || (indexDirectory.trim().isEmpty())) {
            throw new OntopiaRuntimeException("Reference " + ref.getId()
                    + " was marked as fulltext indexable, but 'indexDirectory' configuration is missing");
        }/*from w ww  .  j av  a  2 s  .  c  o m*/
        directoryFile = new File(indexDirectory + File.separatorChar + ref.getId());
    }
}

From source file:com.gnamp.struts.action.TerminalSettingAction.java

private static String _ConfigRoot() {
    try {//  w  w  w  .j a  va  2 s.  co  m
        String classDirectory = TerminalSettingAction.class.getClassLoader().getResource("/").getPath();
        classDirectory = URLDecoder.decode(classDirectory, "UTF-8");
        File f = new File(classDirectory);
        f = f.getParentFile();
        f = f.getParentFile();

        return f.getAbsolutePath() + File.separatorChar + "gnamp_work" + File.separatorChar + "device";
    } catch (Exception ex) {
    }
    return "";
}