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.github.srec.util.ResourceFactory.java

public static File normFile(String s) {
    return new File(s.replace('/', File.separatorChar).replace('\\', File.separatorChar)).getAbsoluteFile();
}

From source file:org.apache.maven.indexer.examples.boot.RepositoryBooter.java

public void createRepositoryStructure(String repositoriesBaseDir, String repositoryName) throws IOException {
    final File repositoriesBasedir = new File(repositoriesBaseDir);
    //noinspection ResultOfMethodCallIgnored
    new File(repositoriesBasedir, repositoryName).mkdirs();
    //noinspection ResultOfMethodCallIgnored
    new File(repositoriesBasedir, repositoryName + File.separatorChar + ".index").mkdirs();

    logger.debug("Created directory structure for repository '" + repositoriesBasedir.getAbsolutePath()
            + File.separatorChar + repositoryName + "'.");
}

From source file:de.jcup.egradle.core.util.FileSupport.java

/**
 * Unzips the given zip file to the given destination directory extracting
 * only those entries the pass through the given filter.
 *
 * @param zipFile//from  ww w .j  a  v  a  2  s.  c  o  m
 *            the zip file to unzip
 * @param dstDir
 *            the destination directory
 * @throws IOException
 *             in case of problem
 */
public void unzip(ZipFile zipFile, File dstDir) throws IOException {

    Enumeration<? extends ZipEntry> entries = zipFile.entries();

    try {
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if (entry.isDirectory()) {
                continue;
            }
            String entryName = entry.getName();
            File file = new File(dstDir, changeSeparator(entryName, '/', File.separatorChar));
            file.getParentFile().mkdirs();
            InputStream src = null;
            OutputStream dst = null;
            try {
                src = zipFile.getInputStream(entry);
                dst = new FileOutputStream(file);
                transferData(src, dst);
            } finally {
                if (dst != null) {
                    try {
                        dst.close();
                    } catch (IOException e) {
                    }
                }
                if (src != null) {
                    src.close();
                }
            }
        }
    } finally {
        try {
            zipFile.close();
        } catch (IOException e) {
        }
    }
}

From source file:org.openmeetings.app.remote.ConferenceLibrary.java

public LibraryPresentation getPresentationPreviewFileExplorer(String SID, String parentFolder) {

    try {/*from   ww  w.  jav  a  2s.c  o  m*/

        Long users_id = sessionManagement.checkSession(SID);
        Long user_level = userManagement.getUserLevelByID(users_id);

        log.debug("#############users_id : " + users_id);
        log.debug("#############user_level : " + user_level);

        if (authLevelManagement.checkUserLevel(user_level)) {

            String current_dir = ScopeApplicationAdapter.webAppPath + File.separatorChar
                    + OpenmeetingsVariables.UPLOAD_DIR;
            String working_dir = current_dir + File.separatorChar + "files" + File.separatorChar + parentFolder;
            log.debug("############# working_dir : " + working_dir);

            File file = new File(working_dir + File.separatorChar + "library.xml");

            if (!file.exists()) {
                throw new Exception(
                        "library.xml does not exist " + working_dir + File.separatorChar + "library.xml");
            }

            return LoadLibraryPresentation.getInstance().parseLibraryFileToObject(file.getAbsolutePath());

        } else {
            throw new Exception("not Authenticated");
        }

    } catch (Exception e) {
        log.error("[getListOfFilesByAbsolutePath]", e);
        return null;
    }

}

From source file:common.AbstractGUI.java

protected void writePNG(JFreeChart jFreeChart, File snapshotDir, String name) {
    if (jFreeChart != null) {
        BufferedImage cpuImage = jFreeChart.createBufferedImage(833, 500);
        File cpuFile = new File(snapshotDir.getPath() + File.separatorChar + name);
        try {/*from w  w  w  . j  a  v  a 2  s. c om*/
            ImageIO.write(cpuImage, "PNG", cpuFile);
        } catch (IOException e) {
            log(e.getMessage());
        }
    }
}

From source file:com.vmware.appfactory.file.FileHelper.java

/**
 * Given a basePath and a list of directory names, check if these
 * construct into a path and if that path exists.
 *
 * Uses default system specific default pathSeparator
 *
 * @see #FileHelper.dirExists(String, char, String...)
 *//*from w  ww  .ja v  a 2s  . co m*/
public static boolean dirExists(String basePath, String... dirNameList) {
    return dirExists(basePath, File.separatorChar, dirNameList);
}

From source file:edu.asu.cse564.samples.crud.io.GradebookIO.java

public String getPath(String fileName) {
    String reponsePath = "";
    try {//from  w w w.  jav  a2 s.c o m
        String path = this.getClass().getClassLoader().getResource("").getPath();
        String fullPath = URLDecoder.decode(path, "UTF-8");
        System.out.println(fullPath);

        // to read a file from webcontent
        String[] pathElements = fullPath.split("/");
        for (String ele : pathElements) {
            if (!ele.equals("CSE564_CRUD_RESTws")) {
                if (ele.length() > 1) {
                    reponsePath += ele + File.separatorChar;
                }
            } else {
                break;
            }
        }
        reponsePath += "CSE564_CRUD_RESTws" + File.separatorChar + fileName;

    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(GradebookIO.class.getName()).log(Level.SEVERE, null, ex);
    }
    return reponsePath;
}

From source file:com.nextep.designer.beng.ui.services.impl.DeliveryExportUIService.java

@Override
public void exportDelivery(final IDeliveryModule module) {
    // Checking container status
    try {//from w w  w.  j a va 2  s .c o m
        IVersionContainer c = (IVersionContainer) VersionHelper.getReferencedItem(module.getModuleRef());
        IVersionable<IVersionContainer> v = VersionHelper.getVersionable(c);
        if (v.getVersion().getStatus() != IVersionStatus.CHECKED_IN) {
            boolean confirmed = MessageDialog.openQuestion(getShell(),
                    BengUIMessages.getString("exportedModuleNotCheckedInTitle"), //$NON-NLS-1$
                    BengUIMessages.getString("exportedModuleNotCheckedIn")); //$NON-NLS-1$
            if (!confirmed) {
                throw new CancelException("Export canceled by the user.");
            }
        }
    } catch (ExternalReferenceException e) {
        // ignoring for now
    }
    // Retrieving output folder
    String folder = SQLGenUtil.getPreference(PreferenceConstants.OUTPUT_FOLDER).trim();
    char lastChar = folder.charAt(folder.length() - 1);
    if (lastChar == File.separatorChar) {
        folder = folder.substring(0, folder.length() - 1);
    }
    // Generating outputs
    String exportLoc = folder + File.separator + module.getName();
    File f = new File(exportLoc);
    boolean newFolder = f.mkdir();
    if (!newFolder) {
        boolean confirmed = MessageDialog.openQuestion(getShell(),
                BengUIMessages.getString("exportLocationExistsTitle"), //$NON-NLS-1$
                BengUIMessages.getString("exportLocationExists")); //$NON-NLS-1$
        if (!confirmed) {
            throw new CancelException("Export canceled by the user.");
        }
    }
    final String targetDirectory = folder;
    // Generating module
    Job j = new BlockingJob("Exporting delivery " + module.getName()) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                exportService.exportDelivery(targetDirectory, module, monitor);
            } catch (UndeliverableIncrementException e) {
                final IDeliveryIncrement dlvInc = e.getDeliveryIncrement();
                // Error property label
                final String titleMsg = e.isUniversal() ? "universalDeliveryNotAllowedTitle"
                        : "prerequisiteFailedTitle";
                final String errorMsg = e.isUniversal() ? "universalDeliveryNotAllowed" : "prerequisiteFailed";
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        MessageDialog.openWarning(
                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                                BengUIMessages.getString(titleMsg),
                                MessageFormat.format(BengUIMessages.getString(errorMsg),
                                        dlvInc.getModule().getName(),
                                        dlvInc.getFromRelease() == null ? "[Scratch]"
                                                : dlvInc.getFromRelease().getLabel(),
                                        dlvInc.getToRelease().getLabel()));
                    }
                });
            }
            return Status.OK_STATUS;
        }
    };
    j.addJobChangeListener(new JobChangeAdapter() {

        public void done(IJobChangeEvent event) {
            if (event.getResult().isOK()) {
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        MessageDialog.openInformation(
                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                                "Exported successfully", "Your delivery has been successfully exported to "
                                        + targetDirectory + File.separator + module.getName() + "."); //$NON-NLS-1$

                    }
                });
            }
        };
    });
    j.setUser(true);
    j.schedule();

}

From source file:dynamicrefactoring.domain.TestExport.java

/**
 * Comprueba que el proceso de exportacin de la refactorizacin dinmica
 * Rename Class a un directorio temporal "./temp" se ha realizado
 * correctamente./* www.j av a 2s .  co  m*/
 * 
 * @throws XMLRefactoringReaderException
 *             XMLRefactoringReaderException.
 * @throws IOException
 *             IOException.
 */
@Test
public void testExportRefactoring() throws XMLRefactoringReaderException, IOException {

    // Primero exportamos la refactorizacin Rename Class a un directorio
    // temporal que luego eliminaremos
    ExportImportUtilities.exportRefactoring(TEMP_DIR, RENAME_CLASS_XML_FILE, false);

    JDOMXMLRefactoringReaderImp reader = new JDOMXMLRefactoringReaderImp();

    for (String element : RefactoringMechanismInstance.getMechanismListClassNames(
            reader.getDynamicRefactoringDefinition(new File(RENAME_CLASS_XML_FILE)).getAllMechanisms())) {

        String name = FilenameUtils.getName(PluginStringUtils.splitGetLast(element, "."));
        String namefolder = FilenameUtils.getName(new File(RENAME_CLASS_XML_FILE).getParent());

        File resultFile = new File(
                TEMP_DIR + File.separatorChar + namefolder + File.separatorChar + name + ".class");
        assertEquals(true, resultFile.exists());
    }

}