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:download.XBRLZipDownloader.java

/**
 * Writes the downloaded file to the hard drive and saves it in the folder structure: date/type/cik.xml
 * @param rssData// w  ww  .  j  a va  2  s .  c o m
 * @throws IOException 
 */
public void downloadXBRLZip(RSSFilingData rssData) throws IOException {
    // gets a system independant file sperator
    String fileSeparator = "" + File.separatorChar;
    // Creates a file path for the output path. The regex reconstructs the format in which
    // the date is represented in the rss data, by removing the day of the month
    // A folder is created for every individual zip file and RSSFilingData object
    String outputPath = XBRLFilePaths.XBRL_FILING_DIRECTORY + fileSeparator
            + rssData.getDate().replaceAll("/([0-9]{2})/", "-") // changes the format of the date to (Month - Year)
            + fileSeparator + rssData.getType() + fileSeparator + rssData.getCik() + fileSeparator
            + rssData.getCik();

    // makes sure the directoris exists in which the file is written to
    validator.validatePath(outputPath);
    // Downloads the zip file and stores it in the given path
    System.out.println(rssData.getURL());
    System.exit(0);
    FileUtils.copyURLToFile(new URL(rssData.getURL()), new File(outputPath + ".zip"));

    System.out.println(outputPath + ".rsd" + "   output path");

    // Saves the rssobjects in the same folder
    saveRSSFilingData(outputPath + ".rsd", rssData);
}

From source file:ch.ivyteam.ivy.maven.BaseEngineProjectMojoTest.java

private static String getLocalRepoPath() {
    String locaRepoGlobalProperty = System.getProperty("maven.repo.local");
    if (locaRepoGlobalProperty != null) {
        return locaRepoGlobalProperty;
    }/*from w ww .  j a  v  a 2s . c o m*/

    StringBuilder defaultHomePath = new StringBuilder(SystemUtils.USER_HOME).append(File.separatorChar)
            .append(".m2").append(File.separatorChar).append("repository");
    return defaultHomePath.toString();
}

From source file:org.psikeds.common.config.ConfigDirectoryHelper.java

/**
 * Try to resolve the configuration directory.
 * //from   w w  w  .  ja va  2s .  c  o  m
 * Note: Yes, method level synchronization is not the most efficient,
 * but we only use it for reading the configuration during application
 * startup, so no need to worry about performance here.
 * 
 * @return File object of the config dir; never null but might
 *         not exist or not be readable!
 */
static synchronized File resolveConfigDir() {
    if (cnfdir == null) {
        String dirname = System.getProperty(CONFIG_DIR_SYSTEM_PROPERTY);
        if (StringUtils.isEmpty(dirname)) {
            final StringBuilder sb = new StringBuilder(System.getProperty("user.home"));
            sb.append(File.separatorChar);
            sb.append(FALLBACK_SUB_DIR);
            dirname = sb.toString();
            LOGGER.info("System property {} not set ... fallback to {}", CONFIG_DIR_SYSTEM_PROPERTY, dirname);
        }
        cnfdir = new File(dirname);
        if (!cnfdir.exists() || !cnfdir.isDirectory() || !cnfdir.canRead()) {
            LOGGER.warn("Configuration directory {} does not exist or is not readable!",
                    cnfdir.getAbsolutePath());
        }
    }
    return cnfdir;
}

From source file:de.lazyzero.kkMulticopterFlashTool.utils.Zip.java

public static File unzipFile(File zipFile, File file) {
    System.out.println("path to zipFile: " + zipFile.getPath());
    System.out.println("file to extract: " + file.getPath());
    String fileName = null;/* ww  w  .j  a va 2  s  .  c o m*/

    try {
        zipFile.mkdir();
        BufferedOutputStream dest = null;
        BufferedInputStream is = null;
        ZipEntry entry;
        ZipFile zipfile = new ZipFile(zipFile);
        Enumeration e = zipfile.entries();
        while (e.hasMoreElements()) {
            entry = (ZipEntry) e.nextElement();
            // System.out.println(entry.getName());
            if (entry.getName().substring(entry.getName().indexOf("/") + 1).equals(file.getName())) {
                //   if (entry.getName().contains(file.getName())){
                System.out.println("firmware to extract found.");

                String tempFolder = System.getProperty("user.dir") + File.separatorChar + "tmp"
                        + File.separatorChar;
                if (System.getProperty("os.name").toLowerCase().contains("mac")) {
                    tempFolder = System.getProperty("user.home")
                            + "/Library/Preferences/kkMulticopterFlashTool/";
                }

                String newDir;
                if (entry.getName().indexOf("/") == -1) {
                    newDir = zipFile.getName().substring(0, zipFile.getName().indexOf("."));
                } else {
                    newDir = entry.getName().substring(0, entry.getName().indexOf("/"));
                }
                String folder = tempFolder + newDir;
                System.out.println("Create folder: " + folder);
                if ((new File(folder).mkdir())) {
                    System.out.println("Done.");
                    ;
                }

                System.out.println("Extracting: " + entry);
                is = new BufferedInputStream(zipfile.getInputStream(entry));
                int count;
                byte data[] = new byte[2048];
                fileName = tempFolder + entry.getName();
                FileOutputStream fos = new FileOutputStream(tempFolder + entry.getName());
                dest = new BufferedOutputStream(fos, 2048);
                while ((count = is.read(data, 0, 2048)) != -1) {
                    dest.write(data, 0, count);
                }
                dest.flush();
                dest.close();
                is.close();
                break;
            }
        }
    } catch (ZipException e) {
        zipFile.delete();
        kk.err(Translatrix._("error.zipfileDamaged"));
        kk.err(Translatrix._("reportProblem"));
    } catch (Exception e) {
        e.printStackTrace();
    }

    return new File(fileName);
}

From source file:org.openmrs.module.appframework.feature.FeatureToggleProperties.java

FeatureToggleProperties() {
    String propertiesFileName = System.getenv(FEATURE_TOGGLE_PROPERTIES_ENV);
    if (propertiesFileName == null) {
        propertiesFileName = OpenmrsUtil.getApplicationDataDirectory() + File.separatorChar
                + FEATURE_TOGGLE_PROPERTIES_FILE_NAME;
    }/* w w w  .j av a2s  .c om*/

    propertiesFile = new File(propertiesFileName);
}

From source file:com.igormaznitsa.jcp.it.maven.ITPreprocessorMojo.java

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    assertNotNull("The test desires the ${maven.home} system property", System.getProperty("maven.home"));

    final String jarFile = System.getProperty("plugin.jar");
    final String pomFile = System.getProperty("project.pom");

    final File testDir = ResourceExtractor.simpleExtractResources(ITPreprocessorMojo.class,
            "dummy_maven_project");
    final Verifier verifier = new Verifier(testDir.getAbsolutePath());

    verifier.assertFilePresent(jarFile);
    verifier.assertFilePresent(pomFile);

    final String processedJarFileName = (jarFile.indexOf(' ') >= 0 ? "\"" + jarFile + "\"" : jarFile)
            .replace('/', File.separatorChar).replace('\\', File.separatorChar);
    final String processedPomFile = (pomFile.indexOf(' ') >= 0 ? "\"" + pomFile + "\"" : pomFile)
            .replace('/', File.separatorChar).replace('\\', File.separatorChar);

    // check that manifest contains main class
    assertMainClass(jarFile, "com.igormaznitsa.jcp.JCPreprocessor");

    verifier.setCliOptions(Arrays.asList("-Dfile=" + processedJarFileName, "-DpomFile=" + processedPomFile));
    verifier.executeGoal("install:install-file");

    verifier.verifyErrorFreeLog();/*from ww w  . j av  a2  s. c om*/
}

From source file:OS.java

public static boolean isUNIX() {
    return File.separatorChar == '/';
}

From source file:at.medevit.elexis.gdt.tools.GDTFileHelper.java

public static <U extends GDTSatzNachricht> boolean writeGDTSatzNachricht(U gdtSatzNachricht,
        IGDTCommunicationPartner cp) {/*from   w  ww  .  j av  a  2 s .c o  m*/
    String[] outLines = gdtSatzNachricht.getMessage();
    String zeichensatz = GDTConstants.getCharsetStringByInt(cp.getOutgoingDefaultCharset());
    String directory = cp.getOutgoingDirectory();
    String outgoingFileName = determineOutgoingFileName(cp);

    try {
        File destination = new File(directory + File.separatorChar + outgoingFileName);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < outLines.length; i++) {
            sb.append(outLines[i]);
        }
        FileUtils.writeStringToFile(destination, sb.toString(), zeichensatz);
    } catch (IOException e) {
        String message = "GDT: Fehler beim Schreiben der Ausgangsdatei " + outgoingFileName;
        Status status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, message, e);
        StatusManager.getManager().handle(status, StatusManager.SHOW);
        logger.log(e, message, Log.WARNINGS);
        return false;
    }
    return true;
}

From source file:eionet.gdem.dcm.conf.DcmProperties.java

public void setDbParams(String url, String user, String psw) throws DCMException {

    String filePath = Properties.appHome + File.separatorChar + "gdem.properties";

    try {/*from   www. j ava  2  s .  c  o  m*/

        BufferedReader reader = new BufferedReader(new FileReader(filePath));
        String line = null;
        StringBuffer st = new StringBuffer();

        while ((line = reader.readLine()) != null) {
            // process the line
            line = findSetProp(line, "db.url", url);
            line = findSetProp(line, "db.user", user);
            line = findSetProp(line, "db.pwd", psw);
            st.append(line);
            st.append("\n");
        }

        BufferedWriter out = new BufferedWriter(new FileWriter(filePath));
        out.write(st.toString());
        out.close();
    } catch (IOException e) {
        LOGGER.error("Saving database parameters failed!", e);
        e.printStackTrace();
        throw new DCMException(BusinessConstants.EXCEPTION_PARAM_DB_FAILED);
    }
}

From source file:cc.recommenders.io.Directory.java

public Directory(String rootDir) {
    String pathSep = Character.toString(File.separatorChar);
    if (rootDir.endsWith(pathSep)) {
        this.rootDir = rootDir;
    } else {// w w  w. ja v  a2 s . co  m
        this.rootDir = rootDir + pathSep;
    }

    File rootFile = new File(rootDir);
    Asserts.assertFalse(rootFile.isFile(), "unable to create directory (is file)");
    if (!rootFile.isDirectory()) {
        rootFile.mkdirs();
        if (!rootFile.isDirectory()) {
            Asserts.fail("unable to create directory");
        }
    }
}