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.igormaznitsa.jcp.expression.functions.AbstractFunctionTest.java

protected File getCurrentTestPath() throws Exception {
    final File root = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
    final String clazz = this.getClass().getCanonicalName().replace('.', File.separatorChar) + ".class";
    return new File(root, clazz);
}

From source file:com.photon.phresco.framework.actions.applications.SiteReport.java

public String checkForSiteReport() {
    S_LOGGER.debug("Entering Method  SiteReport.checkForSiteReport()");

    try {/*from   w  w w .j  a  va2  s . c  o  m*/
        Properties sysProps = System.getProperties();
        S_LOGGER.debug("Phresco FileServer Value of " + PHRESCO_FILE_SERVER_PORT_NO + " is "
                + sysProps.getProperty(PHRESCO_FILE_SERVER_PORT_NO));
        String phrescoFileServerNumber = sysProps.getProperty(PHRESCO_FILE_SERVER_PORT_NO);
        StringBuilder sb = new StringBuilder();
        StringBuilder siteReportPath = new StringBuilder(Utility.getProjectHome());
        siteReportPath.append(projectCode);
        siteReportPath.append(File.separatorChar);
        siteReportPath.append(SITE_TARGET);
        siteReportPath.append(File.separatorChar);
        siteReportPath.append(INDEX_HTML);
        File indexPath = new File(siteReportPath.toString());
        if (indexPath.isFile() && StringUtils.isNotEmpty(phrescoFileServerNumber)) {
            sb.append(HTTP_PROTOCOL);
            sb.append(PROTOCOL_POSTFIX);
            sb.append(LOCALHOST);
            sb.append(COLON);
            sb.append(phrescoFileServerNumber);
            sb.append(FORWARD_SLASH);
            sb.append(projectCode);
            sb.append(FORWARD_SLASH);
            sb.append(SITE_TARGET);
            sb.append(FORWARD_SLASH);
            sb.append(INDEX_HTML);
            getHttpRequest().setAttribute(REQ_SITE_REPORT_PATH, sb.toString());
        } else {
            getHttpRequest().setAttribute(REQ_ERROR, false);
        }
    } catch (Exception e) {
        S_LOGGER.error("Entered into catch block of SiteReport.checkForSiteReport()"
                + FrameworkUtil.getStackTraceAsString(e));
        new LogErrorReport(e, "Getting site report");
    }

    return APP_SITE_REPORT_VIEW;
}

From source file:dynamicrefactoring.domain.xml.ExportImportUtilities.java

/**
 * Se encarga del proceso de exportacin de una refactorizacin dinmica.
 * //  w  ww . j av a  2  s  . c o m
 * @param destination
 *            directorio a donde se quiere exportar la refactorizacin.
 * @param definition
 *            ruta del fichero con la definicin de la refactorizacin.
 * @param createFolders
 *            indica si los ficheros .class se copian en al carpeta raz o
 *            si se genera la estructura de carpetas correspondiente.
 * @throws IOException
 *             IOException.
 * @throws XMLRefactoringReaderException
 *             XMLRefactoringReaderException.
 */
public static void exportRefactoring(String destination, String definition, boolean createFolders)
        throws IOException, XMLRefactoringReaderException {
    String folder = new File(definition).getParent();
    FileManager.copyFolder(folder, destination);
    String refactoringName = FilenameUtils.getName(folder);
    DynamicRefactoringDefinition refact = new JDOMXMLRefactoringReaderImp()
            .getDynamicRefactoringDefinition(new File(definition));

    FileManager.copyFile(new File(RefactoringConstants.DTD_PATH),
            new File(destination + "/" + refactoringName + "/"//$NON-NLS-1$
                    + new File(RefactoringConstants.DTD_PATH).getName()));

    for (RefactoringMechanismInstance mecanismo : refact.getAllMechanisms()) {

        String rule = PluginStringUtils.getMechanismFullyQualifiedName(mecanismo.getType(),
                mecanismo.getClassName());
        final String className = mecanismo.getClassName(); //$NON-NLS-1$

        String rulePath = rule.replace('.', File.separatorChar);

        File currentFile = new File(
                RefactoringConstants.REFACTORING_CLASSES_DIR + File.separatorChar + rulePath + ".class"); //$NON-NLS-1$
        File destinationFile = new File(
                destination + File.separatorChar + refactoringName + File.separatorChar + className + ".class"); //$NON-NLS-1$
        File destinationFolder = new File(destination);
        File newFolder = new File(
                destinationFolder.getParent() + File.separatorChar + new File(rulePath).getParent());
        File newFile = new File(new File(destination).getParent() + File.separatorChar + rulePath + ".class"); //$NON-NLS-1$

        // Si no existe el destino y si el actual
        if (!destinationFile.exists() && currentFile.exists()) {
            if (!createFolders) {
                FileManager.copyFile(currentFile, destinationFile);
            } else {
                if (!newFolder.exists()) {
                    newFolder.mkdirs();
                }
                FileManager.copyFile(currentFile, newFile);
            }
        } else {
            if (!currentFile.exists()) {
                // falta algn fichero .class necesario en esta
                // refactorizacin
                // En este caso se borra la carpeta generada en destino ya
                // que no estar completa
                FileManager.emptyDirectories(destination + File.separatorChar + refactoringName);
                FileManager.deleteDirectories(destination + File.separatorChar + refactoringName, true);
                throw new IOException(Messages.ExportImportUtilities_ClassesNotFound + currentFile.getPath());
            }

        }

    }

}

From source file:com.xceptance.xlt.common.tests.AbstractURLTestCase.java

/**
 * Loading of the data. There is a state variable used to indicate that we already did that.
 * /*from  ww  w  . j  a  v  a  2  s .c o  m*/
 * @throws IOException
 */
@Before
public void loadData() throws IOException {
    login = getProperty("login", getProperty("com.xceptance.xlt.auth.userName"));
    password = getProperty("password", getProperty("com.xceptance.xlt.auth.password"));

    // load the data. Ideally we would offload the file searching to
    // XltProperties.getDataFile(String name)
    // or XltProperties.getDataFile(String name, String locale)
    // or XltProperties.getDataFile(String name, Locale locale)
    final String dataDirectory = XltProperties.getInstance().getProperty(
            XltConstants.XLT_PACKAGE_PATH + ".data.directory", "config" + File.separatorChar + "data");
    final File file = new File(dataDirectory,
            getProperty("filename", Session.getCurrent().getUserName() + ".csv"));

    BufferedReader br = null;
    boolean incorrectLines = false;

    try {
        br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));

        // permit # as comment, empty lines, set comma as separator, and activate the header
        final CSVFormat csvFormat = CSVFormat.RFC4180.toBuilder().withIgnoreEmptyLines(true)
                .withCommentStart('#').withHeader().withIgnoreSurroundingSpaces(true).build();
        final CSVParser parser = new CSVParser(br, csvFormat);
        final Iterator<CSVRecord> csvRecords = parser.iterator();

        // verify header fields to avoid problems with incorrect spelling or spaces
        final Map<String, Integer> headerMap = parser.getHeaderMap();

        for (final String headerField : headerMap.keySet()) {
            if (!CSVBasedURLAction.isPermittedHeaderField(headerField)) {
                Assert.fail(MessageFormat.format("Unsupported or misspelled header field: {0}", headerField));
            }
        }

        // go over all lines, this is a little odd, because we have to catch the iterator exception
        while (true) {
            try {
                final boolean hasNext = csvRecords.hasNext();
                if (!hasNext) {
                    break;
                }
            } catch (final Exception e) {
                // the plus 1 is meant to correct the increment missing because of the exception
                throw new RuntimeException(
                        MessageFormat.format("Line at {0} is invalid, because of <{1}>. Line is ignored.",
                                parser.getLineNumber() + 1, e.getMessage()));
            }

            final CSVRecord csvRecord = csvRecords.next();

            // only take ok lines
            if (csvRecord.isConsistent()) {
                // guard against data exceptions
                try {
                    // do we have an url?
                    if (csvRecord.get(CSVBasedURLAction.URL) != null) {
                        // take it
                        csvBasedActions.add(new CSVBasedURLAction(csvRecord, interpreter));
                    } else {
                        XltLogger.runTimeLogger.error(MessageFormat.format(
                                "Line at {0} does not contain any URL. Line is ignored: {1}",
                                parser.getLineNumber(), csvRecord));
                    }
                } catch (final Exception e) {
                    throw new RuntimeException(MessageFormat.format(
                            "Line at {0} is invalid, because of <{2}>. Line is ignored: {1}",
                            parser.getLineNumber(), csvRecord, e.getMessage()));
                }
            } else {
                XltLogger.runTimeLogger.error(MessageFormat.format(
                        "Line at {0} has not been correctly formatted. Line is ignored: {1}",
                        parser.getLineNumber(), csvRecord));
                incorrectLines = true;
            }
        }
    } finally {
        IOUtils.closeQuietly(br);
    }

    // stop if we have anything the is incorrect, avoid half running test cases
    if (incorrectLines) {
        throw new RuntimeException("Found incorrectly formatted lines. Stopping here.");
    }
}

From source file:com.viadee.acceptancetests.roo.addon.StoryGroupConverter.java

private String storyGroupSearchPath() {
    return _pathResolver.getRoot(Path.SRC_TEST_JAVA) + File.separatorChar
            + _acceptanceTestsUtils.acceptancetestsPackageName().replace(".", File.separator) + File.separator
            + "*Stories.java";
}

From source file:com.norconex.jef4.status.FileJobStatusStore.java

private void resolveDirs() {
    String path = statusDir;//from   w w  w  . ja v  a2 s.com
    if (StringUtils.isBlank(statusDir)) {
        LOG.info("No status directory specified.");
        path = JEFUtil.FALLBACK_WORKDIR.getAbsolutePath();
    } else {
        path = new File(path).getAbsolutePath();
    }
    LOG.debug("Status serialization directory: " + path);
    jobdirLatest = path + File.separatorChar + "latest" + File.separatorChar + "status";
    jobdirBackupBase = path + "/backup";
    File dir = new File(jobdirLatest);
    if (!dir.exists()) {
        try {
            FileUtils.forceMkdir(dir);
        } catch (IOException e) {
            throw new JEFException("Cannot create status directory: " + dir, e);
        }
    }
}

From source file:com.microsoft.office.plugin.AbstractMetadataMojo.java

protected File mkPkgDir(final String path) {
    return mkdir(basePackage.replace('.', File.separatorChar) + File.separator + path);
}

From source file:com.pieframework.runtime.operators.azure.RemoteDesktopOperator.java

private String generateConnectionFile(Role role, String instanceId, String slot) {
    String rdpDirString = ModelStore.getCurrentModel().getConfiguration().getTmp() + "azure"
            + File.separatorChar + "rdp";
    String connectionFileName = role.getParent().getId() + "-" + slot + "-" + role.getId() + "_IN_" + instanceId
            + ".rdp";
    File connectionFile = new File(rdpDirString + File.separatorChar + connectionFileName);
    File rdpDir = new File(rdpDirString);
    AzureHostedService ahs = (AzureHostedService) role.getParent().getResources().get("hostedService");
    AzureRdp ardp = (AzureRdp) role.getResources().get("rdpAccount");
    String username = ardp.getRdpUsername();
    String fqdn = AzureUtils.getHostedServiceFQDN(ahs.getUrlPrefix());

    try {//www  .  jav a2 s . c o  m
        if (!rdpDir.exists()) {
            rdpDir.mkdirs();
        }

        BufferedWriter out = new BufferedWriter(new FileWriter(connectionFile.getPath()));
        out.write("full address:s:" + fqdn);
        out.newLine();
        out.write("username:s:" + username);
        out.newLine();
        out.write("LoadBalanceInfo:s:Cookie: mstshash=" + role.getId() + "#" + role.getId() + "_IN_"
                + instanceId + "#Microsoft.WindowsAzure.Plugins.RemoteAccess.Rdp");
        out.close();

    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return connectionFile.getPath();
}

From source file:com.norconex.jef4.log.FileLogManager.java

private void resolveDirs() {
    String path = logdir;/*from  w w w  .j  a  v  a2s. c  o  m*/
    if (StringUtils.isBlank(logdir)) {
        path = JEFUtil.FALLBACK_WORKDIR.getAbsolutePath();
    } else {
        path = new File(path).getAbsolutePath();
    }

    LOG.debug("Log directory: " + path);
    logdirLatest = path + File.separatorChar + "latest" + File.separatorChar + "logs";
    logdirBackupBase = path + "/backup";
    File dir = new File(logdirLatest);
    if (!dir.exists()) {
        if (!dir.exists()) {
            try {
                FileUtils.forceMkdir(dir);
            } catch (IOException e) {
                throw new JEFException("Cannot create log directory: " + logdirLatest, e);
            }
        }
    }
}

From source file:com.eviware.soapui.impl.wsdl.support.wsdl.CachedWsdlLoader.java

public String saveDefinition(String folderName) throws Exception {
    File outFolder = new File(folderName);
    if (!outFolder.exists() && !outFolder.mkdirs())
        throw new Exception("Failed to create directory [" + folderName + "]");

    Map<String, String> urlToFileMap = new HashMap<String, String>();

    setFilenameForUrl(config.getRootPart(), Constants.WSDL11_NS, urlToFileMap);

    List<DefintionPartConfig> partList = config.getPartList();
    for (DefintionPartConfig part : partList) {
        setFilenameForUrl(part.getUrl(), part.getType(), urlToFileMap);
    }//from   www.ja  v a  2 s  .co m

    for (DefintionPartConfig part : partList) {
        XmlObject obj = XmlObject.Factory.parse(part.getContent().toString());
        replaceImportsAndIncludes(obj, urlToFileMap, part.getUrl());
        obj.save(new File(outFolder, urlToFileMap.get(part.getUrl())));
    }

    return folderName + File.separatorChar + urlToFileMap.get(config.getRootPart());
}