List of usage examples for org.apache.commons.io FilenameUtils separatorsToSystem
public static String separatorsToSystem(String path)
From source file:com.consol.citrus.admin.controller.ProjectController.java
@RequestMapping(method = RequestMethod.POST) @ResponseBody//from ww w.j a va2 s. c om public ModelAndView browseProjectHome(@RequestParam("dir") String dir) { String directory = FilenameUtils .separatorsToSystem(fileHelper.decodeDirectoryUrl(dir, configurationService.getRootDirectory())); String[] folders = fileHelper.getFolders(new File(directory)); ModelAndView view = new ModelAndView("FileTree"); view.addObject("folders", folders); view.addObject("baseDir", FilenameUtils.separatorsToUnix(directory)); return view; }
From source file:com.googlecode.fascinator.common.FascinatorHome.java
/** * Gets a relative directory inside the Fascinator home directory. * // w ww .ja v a2 s. c om * @param subDir the directory name * @return a directory path */ public static String getPath(String subDir) { return getPath() + File.separator + FilenameUtils.separatorsToSystem(subDir); }
From source file:net.erdfelt.android.sdkfido.project.Dir.java
public Dir getSubDir(String path) { return new Dir(new File(this.basedir, FilenameUtils.separatorsToSystem(path))); }
From source file:com.pieframework.runtime.utils.Zipper.java
public static void unzip(String zipFile, String toDir) throws ZipException, IOException { int BUFFER = 2048; File file = new File(zipFile); ZipFile zip = new ZipFile(file); String newPath = toDir;/*from ww w.j a va 2 s. c o m*/ File toDirectory = new File(newPath); if (!toDirectory.exists()) { toDirectory.mkdir(); } Enumeration zipFileEntries = zip.entries(); // Process each entry while (zipFileEntries.hasMoreElements()) { // grab a zip file entry ZipEntry entry = (ZipEntry) zipFileEntries.nextElement(); String currentEntry = entry.getName(); File destFile = new File(newPath, FilenameUtils.separatorsToSystem(currentEntry)); //System.out.println(currentEntry); File destinationParent = destFile.getParentFile(); // create the parent directory structure if needed destinationParent.mkdirs(); if (!entry.isDirectory()) { BufferedInputStream is = new BufferedInputStream(zip.getInputStream(entry)); int currentByte; // establish buffer for writing file byte data[] = new byte[BUFFER]; // write the current file to disk FileOutputStream fos = new FileOutputStream(destFile); BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER); // read and write until last byte is encountered while ((currentByte = is.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, currentByte); } dest.flush(); dest.close(); is.close(); } } zip.close(); }
From source file:com.consol.citrus.admin.controller.TestCaseController.java
@RequestMapping(method = { RequestMethod.POST }) @ResponseBody/*from w w w . j a v a2 s . com*/ public ModelAndView list(@RequestParam("dir") String dir) { ModelAndView view = new ModelAndView("TestFileTree"); FileTreeModel model = testCaseService .getTestFileTree(FilenameUtils.separatorsToSystem(fileHelper.decodeDirectoryUrl(dir, ""))); if (StringUtils.hasText(model.getCompactFolder())) { view.addObject("compactFolder", FilenameUtils.separatorsToUnix(model.getCompactFolder())); view.addObject("baseDir", FilenameUtils.separatorsToUnix( fileHelper.decodeDirectoryUrl(dir, "") + model.getCompactFolder() + File.separator)); } else { view.addObject("baseDir", FilenameUtils.separatorsToUnix(fileHelper.decodeDirectoryUrl(dir, ""))); } view.addObject("folders", model.getFolders()); view.addObject("xmlFiles", model.getXmlFiles()); view.addObject("javaFiles", model.getJavaFiles()); return view; }
From source file:edu.ur.file.db.FileDatabaseTest.java
/** * Test adding a root folder to the file database. * @throws LocationAlreadyExistsException */// w w w. ja v a 2 s. c o m public void createRootFolderTest() throws LocationAlreadyExistsException { DefaultFileServer fs = new DefaultFileServer(); String databasePath = FilenameUtils.separatorsToSystem(properties.getProperty("FileDatabaseTest.db_path")); assert databasePath != null : "Path should not be null"; DefaultFileDatabase fileDatabaseImpl = fs.createFileDatabase("displayName", "dbName_1", databasePath, "dbDescription"); fileDatabaseImpl.setId(44l); assert fileDatabaseImpl.getPrefix() != null : "Prefix should not be null but is"; assert fileDatabaseImpl.getPath() != null : "Base path shouldn't be null"; assert fileDatabaseImpl.getPath().equals(databasePath) : " Path should equal " + databasePath + " but is " + fileDatabaseImpl.getPath(); TreeFolderInfo folder = fileDatabaseImpl.createRootFolder("rootFolder", "folderName"); assert folder.getPath().equals(fileDatabaseImpl.getFullPath()) : "folder should have " + " path equal to file database full path folder path = " + folder.getPath() + " file database path = " + fileDatabaseImpl.getFullPath(); assert fileDatabaseImpl.setCurrentFileStore(folder.getName()) : "Folder to store files should be set"; assert fileDatabaseImpl.getCurrentFileStore().equals(folder) : "File Store should equal folder"; TreeFolderInfo child = fileDatabaseImpl.getRootFolder("folderName").createChild("newDbFolder", "newDbFolder"); assert child.getParent() == folder : "Child should have parent folder"; assert child.getBasePath().equals(folder.getBasePath()) : "Child folder base path = " + child.getBasePath() + " parent folder path = " + folder.getBasePath(); assert child.getPath().equals(folder.getFullPath()) : "Childs path = " + child.getPath() + " should equal the " + "parents full path = " + folder.getFullPath(); File f = new File(child.getFullPath()); assert f.exists() : "Child folder should exist for full path " + child.getFullPath(); File root = new File(folder.getFullPath()); assert root.exists() : "Root folder " + root.getAbsolutePath() + " should exist"; fileDatabaseImpl.removeRootFolder(folder); assert !root.exists() : "Root folder " + root.getAbsolutePath() + " should no longer exist"; fs.deleteFileServer(); }
From source file:com.bibisco.manager.ContextManager.java
private ContextManager() { ConfigManager lConfigManager = ConfigManager.getInstance(); // os/*from ww w . j a va2 s . c o m*/ mStrOS = calculateOSName(); // test or production String lStrTestEnabled = lConfigManager.getMandatoryProperty("test/@enabled"); mBlnTest = "Y".equalsIgnoreCase(lStrTestEnabled); // absolute path if (mBlnTest) { mStrAbsolutePath = lConfigManager.getProperty("test/" + mStrOS + "/@basePath"); } else { String lStrPath = Platform.getInstallLocation().getURL().getPath(); if ("win".equalsIgnoreCase(mStrOS)) { // remove the first slash to have the correct path on windows lStrPath = lStrPath.substring(1); } mStrAbsolutePath = FilenameUtils.separatorsToSystem(lStrPath); } // web URI mURIWeb = UriBuilder.fromUri(lConfigManager.getMandatoryProperty("web/@uri")).build(); // file separator mStrPathSeparator = getPathSeparator(); StringBuilder lStringBuilder = new StringBuilder(); // db directory path lStringBuilder = new StringBuilder(); lStringBuilder.append(mStrAbsolutePath); lStringBuilder.append("db"); lStringBuilder.append(mStrPathSeparator); mStrDbDirectoryPath = lStringBuilder.toString(); // temp directory path lStringBuilder = new StringBuilder(); lStringBuilder.append(mStrAbsolutePath); lStringBuilder.append("temp"); lStringBuilder.append(mStrPathSeparator); mStrTempDirectoryPath = lStringBuilder.toString(); // export directory path lStringBuilder = new StringBuilder(); lStringBuilder.append(mStrAbsolutePath); lStringBuilder.append("export"); lStringBuilder.append(mStrPathSeparator); mStrExportDirectoryPath = lStringBuilder.toString(); // template db directory path lStringBuilder = new StringBuilder(); lStringBuilder.append(mStrAbsolutePath); lStringBuilder.append("db"); lStringBuilder.append(mStrPathSeparator); lStringBuilder.append("template"); lStringBuilder.append(mStrPathSeparator); mStrTemplateDbDirectoryPath = lStringBuilder.toString(); // xulrunner directory path lStringBuilder = new StringBuilder(); lStringBuilder.append(mStrAbsolutePath); lStringBuilder.append("xulrunner"); lStringBuilder.append(mStrPathSeparator); lStringBuilder.append(mStrOS); mStrXulRunnerDirectoryPath = lStringBuilder.toString(); mLog.info("*** OS: ", mStrOS); mLog.info("*** Absolute path: ", mStrAbsolutePath); mLog.info("*** db: ", mStrDbDirectoryPath); mLog.info("*** export: ", mStrExportDirectoryPath); mLog.info("*** temp: ", mStrTempDirectoryPath); mLog.info("*** Template db directory path: ", mStrTemplateDbDirectoryPath); mLog.info("*** Xulrunner directory path: ", mStrXulRunnerDirectoryPath); }
From source file:com.epam.wilma.stubconfig.cache.cleaner.helper.StubConfigPathProvider.java
/** * This method provides the paths of selecting with the given pattern. This pattern is like endsWith. * * @param sourceFolderPath is the relative path of a folder * @param pattern is a pattern, example: *something.xml -> ABsomething.xml, Asomething.xml * @return List<String> which contains paths of result files of the selecting. */// w w w .java 2s. c o m public List<String> getConfigPathsFromSpecificFolder(final String sourceFolderPath, final String pattern) { List<String> resultPaths = new ArrayList<>(); if (!pattern.contains("*")) { String specificFilePath; if ("".equals(sourceFolderPath)) { specificFilePath = pattern; } else { specificFilePath = FilenameUtils.separatorsToSystem(sourceFolderPath + "/" + pattern); } resultPaths.add(specificFilePath); } else { File folder = new File(sourceFolderPath); folder = folder.getAbsoluteFile(); int cutFromHere = pattern.indexOf("*") + 1; String endOfFiles = pattern.substring(cutFromHere); for (File file : fileUtils.listFilesWithFilter(folder, "^(.+)" + endOfFiles + "$")) { resultPaths.add(file.getPath()); } } return resultPaths; }
From source file:it.unibas.spicy.persistence.idgenerator.utils.ExportDB.java
private ArrayList<String> getExportDatabaseConfig() throws FileNotFoundException, IOException { ArrayList<String> config = new ArrayList<>(); BufferedReader in = new BufferedReader(new FileReader(FilenameUtils.separatorsToSystem(this.path))); try {// w ww . j a va 2 s . com String line; while ((line = in.readLine()) != null) { config.add(line.split("=")[1].trim()); } } catch (IOException ex) { System.err.print(ex); System.exit(-1); } finally { in.close(); } return config; }
From source file:net.erdfelt.android.sdkfido.local.LocalAndroidPlatformsTest.java
private void assertIsTestPlatform4(String prefix, File sdkDir, AndroidPlatform plat4) throws IOException { Assert.assertThat(prefix, plat4, notNullValue()); File expectedDir = new File(sdkDir, FilenameUtils.separatorsToSystem("platforms/android-4")); PathAssert.assertDirExists("Expected Testing Platform Dir", expectedDir); Assert.assertThat(prefix + ".dir", plat4.getDir(), is(expectedDir)); Assert.assertThat(prefix + ".apiLevel", plat4.getApiLevel(), is(4)); Assert.assertThat(prefix + ".description", plat4.getDescription(), is("Android SDK Platform 1.6_r2")); Assert.assertThat(prefix + ".version", plat4.getVersion(), is("1.6")); JarListing jar4 = plat4.getAndroidJarListing(); Assert.assertThat(prefix + ".androidJarListing", jar4, notNullValue()); Assert.assertThat(prefix + ".androidJarListing.size", jar4.size(), is(3509)); List<String> classlist = jar4.getClassList(); Assert.assertThat(prefix + ".androidJarListing.classlist.size", classlist.size(), is(2400)); }