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.sic.bb.jenkins.plugins.sicci_for_xcode.util.ExtendedFile.java

private static void zipDirectory(File file, String path, ZipArchiveOutputStream zipStream)
        throws IOException, InterruptedException {
    if (path == null)
        path = new String();
    else if (!path.isEmpty())
        path += File.separatorChar;

    ZipArchiveEntry zipEntry = new ZipArchiveEntry(file, path + file.getName());
    zipEntry.setUnixMode(PosixAPI.get().stat(file.getAbsolutePath()).mode());

    /* TODO: archiving symlinks doesn't work atm
    zipEntry.setUnixMode(PosixAPI.get().stat(file.getAbsolutePath()).mode());
            /*w w w .  j a  v a2s . com*/
    if(Util.isSymlink(file)) {
       zipEntry = new ZipArchiveEntry(path + file.getName());
       zipEntry.setUnixMode(PosixAPI.get().stat(file.getAbsolutePath()).mode());
               
       AsiExtraField field = new AsiExtraField();
       field.setLinkedFile(path + file.getName());
               
       zipEntry.addExtraField(field);
        zipStream.putArchiveEntry(zipEntry);
      zipStream.closeArchiveEntry();
        return;
    }
    */

    zipStream.putArchiveEntry(zipEntry);

    if (!file.isDirectory()) {
        FileInputStream fileInputStream = null;

        try {
            fileInputStream = new FileInputStream(file);
            Util.copyStream(fileInputStream, zipStream);
        } finally {
            IOUtils.closeQuietly(fileInputStream);
            zipStream.closeArchiveEntry();
        }
    } else {
        zipStream.closeArchiveEntry();

        String[] entries = file.list();

        if (entries != null)
            for (String entry : entries)
                zipDirectory(new File(file, entry), path + file.getName(), zipStream);
    }
}

From source file:com.heliosdecompiler.helios.transformers.assemblers.KrakatauAssembler.java

@Override
public byte[] assemble(String name, String contents) {
    if (Helios.ensurePython2Set()) {
        File tempFolder = null;/*from   w  w  w .j ava  2  s.com*/
        File tempFile = null;
        String processLog = "";
        try {
            tempFolder = Files.createTempDirectory("ka").toFile();
            tempFile = new File(tempFolder, name.replace('/', File.separatorChar) + ".j");
            FileUtils.write(tempFile, contents, "UTF-8", false);
            Process process = Helios
                    .launchProcess(new ProcessBuilder(Settings.PYTHON2_LOCATION.get().asString(), "-O",
                            "assemble.py", "-out", tempFolder.getAbsolutePath(), tempFile.getAbsolutePath())
                                    .directory(Constants.KRAKATAU_DIR));

            processLog = Utils.readProcess(process);

            return FileUtils.readFileToByteArray(new File(tempFile.toString().replace(".j", ".class")));
        } catch (Exception e) {
            ExceptionHandler.handle(e);
            SWTUtil.showMessage(processLog);
        } finally {
            try {
                if (tempFolder != null) {
                    FileUtils.deleteDirectory(tempFolder);
                }
            } catch (IOException e) {
            }
            if (tempFile != null) {
                tempFile.delete();
            }
        }
    } else {
        SWTUtil.showMessage("You need to set Python!");
    }
    return null;
}

From source file:com.flexive.shared.FxFileUtils.java

/**
 * Expand the path by replacing '~' with the user home directory and fix file separator chars
 *
 * @param path the path to expand//from  w w  w.ja v  a2s .co m
 * @return expanded path
 */
public static String expandPath(String path) {
    //fix file separators
    if (File.separatorChar == '/')
        path = path.replace('\\', '/');
    else
        path = path.replace('/', '\\');
    //expand ~ to user home
    if (path.indexOf("~") >= 0)
        path = path.replaceAll("~", System.getProperty("user.home"));
    return path;
}

From source file:com.px100systems.data.utility.BackupFile.java

public BackupFile(String directory, String unitName) {
    file = new File(directory + File.separatorChar + unitName + EXTENSION);
}

From source file:de.thb.ue.backend.service.AnswerImageService.java

@Override
public void addAnswerImage(Vote vote, MultipartFile answerImage, String evaluationID) {
    File imageFolder = new File(
            (workingDirectoryPath.isEmpty() ? "" : (workingDirectoryPath + File.separatorChar)) + evaluationID
                    + File.separatorChar + "images");
    try {//from  w  w  w  .  j a va  2s  .c  o m
        if (!imageFolder.exists()) {
            FileUtils.forceMkdir(imageFolder);
        }
        BufferedOutputStream stream = new BufferedOutputStream(
                new FileOutputStream(new File(imageFolder, vote.getId() + ".zip")));
        stream.write(answerImage.getBytes());
        stream.close();
    } catch (IOException e) {
        //TODO
        e.printStackTrace();
    }
}

From source file:org.eclipse.gemini.blueprint.test.parsing.CaseWithVisibleMethodsBaseTest.java

public String getRootPath() {
    ResourceLoader fileLoader = new DefaultResourceLoader();
    try {//from   w  w w.j a  v a2s.co m
        String classFile = CaseWithVisibleMethodsBaseTest.class.getName().replace('.', '/').concat(".class");
        Resource res = fileLoader.getResource(classFile);
        String fileLocation = "file:/" + res.getFile().getAbsolutePath();
        String classFileToPlatform = CaseWithVisibleMethodsBaseTest.class.getName()
                .replace('.', File.separatorChar).concat(".class");
        return fileLocation.substring(0, fileLocation.indexOf(classFileToPlatform));
    } catch (Exception ex) {
    }

    return null;
}

From source file:com.jaxio.celerio.output.FileTracker.java

private String getFilename() {
    return generatedFileLocation + File.separatorChar + "generated.xml";
}

From source file:de.fabianonline.telegram_backup.ApiStorage.java

public void setPrefix(String prefix) {
    this.prefix = prefix;
    this.do_save = (this.prefix != null);
    if (this.do_save) {
        String base = Config.FILE_BASE + File.separatorChar + this.prefix + File.separatorChar;
        this.file_auth_key = new File(base + Config.FILE_NAME_AUTH_KEY);
        this.file_dc = new File(base + Config.FILE_NAME_DC);
        this._saveAuthKey();
        this._saveDc();
    } else {/*  ww  w .  ja v a  2  s.  co m*/
        this.file_auth_key = null;
        this.file_dc = null;
    }
}

From source file:com.jaxio.celerio.output.FolderSourceFile.java

@Override
public String getFullPath(String pathToFile) {
    return directory + File.separatorChar + normalize(pathToFile);
}

From source file:net.menthor.editor.v2.util.Util.java

public static String getCanonPath(String dir, String fileName) {
    return canon(dir + File.separatorChar + fileName);
}