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:com.googlecode.jgenhtml.JGenXmlTest.java

/**
 *
 * @param relativePathToFile The path to the file relative to the output directory (i.e. no leading file separator).
 * @return The file you want/*from ww  w  .j av a  2s.co  m*/
 */
private File getReportFile(final String relativePathToFile) {
    File outputDir = JGenHtmlTestUtils.getTestDir();
    String outputDirPath = outputDir.getAbsolutePath();
    String absPathToFile = outputDirPath + File.separatorChar + relativePathToFile;
    File result = new File(absPathToFile);
    return result;
}

From source file:com.thoughtworks.go.server.service.lookups.CommandRepositoryDirectoryWalkerTest.java

@Test
void shouldProcessXmlFilesInsideCommandRepo() throws Exception {
    File command_repo = temporaryFolder.newFolder("command-repo");
    File windows = new File(command_repo, "windows");
    windows.mkdirs();//from  w  w  w  .  j  a  va 2s.co m
    FileUtils.writeStringToFile(new File(windows, "msbuild.xml"),
            CommandSnippetMother.validXMLSnippetContentForCommand("MsBuild"), UTF_8);

    CommandSnippets results = walker.getAllCommandSnippets(command_repo.getPath());

    String expectedRelativePath = "/windows/msbuild.xml".replace('/', File.separatorChar);
    assertThat(results).isEqualTo(new CommandSnippets(
            Arrays.asList(new CommandSnippet("MsBuild", Arrays.asList("pack", "component.nuspec"),
                    new EmptySnippetComment(), "msbuild", expectedRelativePath))));
}

From source file:marytts.util.string.StringUtils.java

public static String checkLastSlash(String strIn) {
    String strOut = strIn;//w w  w  . j av  a  2s  .  c o m

    char last = strIn.charAt(strIn.length() - 1);

    if (last != File.separatorChar && last != '\\' && last != '/')
        strOut = strOut + "/";

    return strOut;
}

From source file:de.ingrid.interfaces.csw.cache.AbstractFileCache.java

/**
 * Get the relative path to a document starting from the cache root
 * //  w w w .j  a va 2  s.c o m
 * @param id
 * @param elementSetName
 * @return String
 */
protected String getAbsolutePath(Serializable id) {
    StringBuilder buf = new StringBuilder();
    buf.append(this.getWorkPath()).append(File.separatorChar).append(this.getRelativePath(id));
    return new File(buf.toString()).getAbsolutePath();
}

From source file:org.gallery.web.controller.FileController.java

@RequestMapping(value = "/downloadfile/{id}", params = { "attachment" }, method = RequestMethod.GET)
public void download(HttpServletResponse response, @PathVariable("id") Long id,
        @RequestParam("attachment") boolean attachment) {

    log.info("downloadfile called...");
    DataFileEntity entity = dataFileDao.getById(id);
    if (entity == null) {
        return;/*from   w w  w.j  a  v a  2 s .  c o  m*/
    } else {
        String realPath = fileUploadDirectory + File.separatorChar + entity.getKey();
        File file = new File(realPath);
        response.setContentType(entity.getContentType());
        response.setContentLength(entity.getSize().intValue());
        if (attachment)
            try {
                response.setHeader("Content-Disposition",
                        "attachment; filename=" + java.net.URLEncoder.encode(entity.getName(), "UTF-8"));
            } catch (UnsupportedEncodingException e1) {
                // TODO Auto-generated catch block
                log.error("Could not  encode " + entity.getName(), e1);
            }
        try {
            InputStream is = new FileInputStream(file);
            IOUtils.copy(is, response.getOutputStream());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            log.error("Could not  download: " + entity.toString(), e);
        }
    }
}

From source file:com.flipkart.poseidon.serviceclients.generator.Generator.java

private static void generate() throws Exception {
    String idlBasePath = IDL_BASE_PATH.replace('.', File.separatorChar);
    File pojoFolder = new File(modulePath + idlBasePath + POJO_FOLDER_NAME);
    generatePojo(pojoFolder);//from  w w  w  . j  a v  a  2  s  . c  om

    File serviceFolder = new File(modulePath + idlBasePath + SERVICE_FOLDER_NAME);
    generateService(serviceFolder);
}

From source file:com.stimulus.archiva.domain.FileSystem.java

public String getConfigurationPath() {
    return getDir(applicationPath + File.separatorChar + "WEB-INF" + File.separatorChar + "conf");
}

From source file:neembuu.uploader.zip.generator.NUZipFileGenerator.java

private Class load(Path f, Path uploadersDirectory) throws Exception {
    String p = uploadersDirectory.normalize().relativize(f.normalize()).toString();
    p = p.replace(File.separatorChar, '.');
    p = p.substring(0, p.lastIndexOf('.'));//to remove .class
    return classLoader.loadClass(p);
}

From source file:mx.itesm.imb.ImbOperationsImpl.java

/**
 * @see mx.itesm.imb.ImbCommands#updateControllers()
 *///w  w w  .  j  av  a 2  s .com
public void updateControllers() {
    String antPath;
    String packageName;
    File controllerFile;
    FileDetails srcRoot;
    File configurationFile;
    String configurationPath;
    String configurationContents;
    SortedSet<FileDetails> entries;

    // Identify mvc-controllers
    antPath = pathResolver.getRoot(Path.SRC_MAIN_JAVA) + File.separatorChar + "**" + File.separatorChar
            + "*Controller.java";
    srcRoot = new FileDetails(new File(pathResolver.getRoot(Path.SRC_MAIN_JAVA)), null);
    entries = fileManager.findMatchingAntPath(antPath);

    // Update mvc-controller's methods to allow communication with the IMB
    for (FileDetails file : entries) {
        try {
            controllerFile = file.getFile();
            packageName = srcRoot.getRelativeSegment(file.getCanonicalPath()).replace(File.separatorChar, '.');
            packageName = packageName.substring(1).substring(0, packageName.lastIndexOf('.') - 1); // java
            packageName = packageName.substring(0, packageName.lastIndexOf('.')); // className
            this.writeImbAspect(
                    controllerFile.getName().substring(0, controllerFile.getName().indexOf(".java")),
                    packageName, controllerFile.getParentFile().getAbsolutePath());
            logger.log(Level.INFO, file.getCanonicalPath() + " controller updated");
        } catch (Exception e) {
            logger.log(Level.SEVERE,
                    "Error while updating " + file.getCanonicalPath() + " controller: " + e.getMessage());
        }
    }

    // Update Rest configuration
    try {
        configurationFile = new File(pathResolver.getRoot(Path.SRC_MAIN_RESOURCES)
                + "/META-INF/spring/applicationContext-contentresolver.xml");
        configurationContents = FileUtils.readFileToString(configurationFile);

        // TODO: Change to classpath search
        configurationContents = configurationContents.replace("</beans>",
                FileUtils.readFileToString(new File(
                        "/Users/jccastrejon/java/workspace_IMB/InstanceModelBus.Roo/src/main/resources",
                        "RestTemplate.vml")) + "</beans>");
        FileUtils.writeStringToFile(configurationFile, configurationContents);
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error updating Rest configuration: " + e.getMessage());
    }

    // Configuration file
    try {
        configurationPath = pathResolver.getIdentifier(Path.SRC_MAIN_RESOURCES,
                "/mx/itesm/imb/configuration.properties");
        this.createFile(configurationPath, "configuration_template.properties");
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error updating configuration file: " + e.getMessage());
    }
}

From source file:com.pieframework.runtime.utils.ArtifactManager.java

public static String generateDeployPath(String basePath, boolean unArchive, String query) {
    String result = null;//from   w ww. ja v a2  s .c  o m

    //Locate the files in the local artifact cache
    Configuration.log().debug("artifact location:" + basePath + " query:" + query);
    List<File> flist = ResourceLoader.findPath(basePath, query);

    //System.out.println(flist.size() +" "+basePath +" "+query);

    if (!flist.isEmpty()) {
        String archivePath = getArchivePath(flist);
        if (!StringUtils.empty(archivePath)) {
            //Create a temp location
            File archiveFile = new File(archivePath);
            String tmpPath = ResourceLoader.getDeployRoot() + ResourceLoader.getResourceName(query)
                    + File.separatorChar + TimeUtils.getCurrentTimeStamp() + File.separatorChar
                    + FilenameUtils.getName(archiveFile.getParent());

            File tmpDir = new File(tmpPath);
            if (tmpDir.isDirectory() && !tmpDir.exists()) {
                tmpDir.mkdirs();
            }

            //Unarchive the file
            try {
                Zipper.unzip(archivePath, tmpPath);
                result = tmpPath;
            } catch (Exception e) {
                //TODO throw error
                e.printStackTrace();
            }

        } else {
            result = getCommonPathRoot(flist);
        }
    } else {
        throw new RuntimeException(
                "Failed locating path for artifact. searchroot:" + basePath + " query:" + query);
    }
    return result;
}