List of usage examples for org.apache.commons.io FilenameUtils separatorsToSystem
public static String separatorsToSystem(String path)
From source file:dynamicrefactoring.domain.TestImport.java
private String getMoonRefactoryDir() { return FilenameUtils .separatorsToSystem(RefactoringConstants.REFACTORING_CLASSES_DIR + "repository\\moon\\"); }
From source file:dynamicrefactoring.domain.TestImport.java
private String getRenameClassXmlFile() { return FilenameUtils.separatorsToSystem(getRenameClassDir() + "\\Rename Class.xml"); }
From source file:dynamicrefactoring.domain.TestImport.java
private String getRenameClassDir() { return FilenameUtils.separatorsToSystem(RefactoringPlugin.getDynamicRefactoringsDir() + "\\Rename Class"); }
From source file:net.erdfelt.android.sdkfido.configer.ConfigCmdLineParserTest.java
@Test public void testSaveConfig() throws CmdLineParseException, IOException { testingdir.ensureEmpty();/* w ww .java 2 s . c o m*/ FetcherConfig config = new FetcherConfig(); File expectedDir = new File(SystemUtils.getUserHome(), FilenameUtils.separatorsToSystem(".sdkfido/work")); Assert.assertThat("Config.dryRun", config.isDryRun(), is(false)); Assert.assertThat("Config.workDir", config.getWorkDir(), is(expectedDir)); Assert.assertThat("Config.outputType", config.getOutputType(), is(OutputProjectType.SDK)); File confFile = testingdir.getFile("config.properties"); StringWriter capture = new StringWriter(); ConfigCmdLineParser parser = new ConfigCmdLineParser(this, config); parser.setOut(capture); String[] args = { "--save-config", "--config", confFile.getAbsolutePath() }; parser.parse(args); PathAssert.assertFileExists("Config File", confFile); Properties props = loadProps(confFile); Assert.assertThat("props[dryRun]", props.getProperty("dryRun"), is("false")); Assert.assertThat("props[workDir]", props.getProperty("workDir"), is(expectedDir.getAbsolutePath())); Assert.assertThat("props[outputType]", props.getProperty("outputType"), is("SDK")); }
From source file:com.ariht.maven.plugins.config.ConfigProcessorMojo.java
private void logConfigurationParameters() { if (StringUtils.isBlank(encoding)) { encoding = System.getProperty("file.encoding"); getLog().warn("File encoding has not been set, using platform encoding '" + encoding + "', i.e. generated config is platform dependent!"); } else if (logOutput) { getLog().info("Using file encoding '" + encoding + "' while generating config."); }// w w w. j av a 2 s. c o m if (logOutput) { getLog().info(MessageFormat.format("templatesBasePath : {0}", FilenameUtils.separatorsToSystem(templatesBasePath))); getLog().info(MessageFormat.format("filtersBasePath : {0}", FilenameUtils.separatorsToSystem(filtersBasePath))); getLog().info(MessageFormat.format("outputBasePath : {0}", FilenameUtils.separatorsToSystem(outputBasePath))); } }
From source file:edu.ur.file.db.FileDatabaseTest.java
/** * Test re-naming the file database.//from w ww.j av a2 s. c o m * @throws LocationAlreadyExistsException */ public void databaseReNameTest() 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_2", "dbName_2", 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(); File f = new File(fileDatabaseImpl.getFullPath()); assert f.exists() : "File database " + f.getAbsolutePath() + " should exist"; fs.renameFileDatabase(fileDatabaseImpl.getName(), "renameDbName_2"); assert fs.getFileDatabases().contains(fileDatabaseImpl) : "File database should contain file database " + fileDatabaseImpl; File fNew = new File(fileDatabaseImpl.getPath() + "renameDbName_2"); assert fNew.exists() : "New file database " + fNew.getAbsolutePath() + " should exist"; assert !f.exists() : " Old location should no longer exist " + f.getAbsolutePath(); fs.deleteFileServer(); }
From source file:edu.ur.file.db.FileSystemManagerTest.java
/** * Test moving a folder. /*www .j a va 2s . co m*/ * @throws LocationAlreadyExistsException * @throws IllegalFileSystemNameException */ @Test public void moveFolderWithFilesTest() throws LocationAlreadyExistsException, IllegalFileSystemNameException { // create a file server with the specified path String serverPath = properties.getProperty("FileSystemManagerTest.move.initial"); DefaultFileServer server = new DefaultFileServer("fileServer"); DefaultFileDatabase fd = server.createFileDatabase("displayName11", "fileDB_11", serverPath, "description"); TreeFolderInfo infoCurrent = FileSystemManager.createFolder("start1", fd); File f = new File(infoCurrent.getFullPath()); assert f.exists() : "Folder should be created"; // create the first file to store in the temporary folder String tempDirectory = properties.getProperty("file_db_temp_directory"); File directory = new File(tempDirectory); // helper to create the file FileUtil testUtil = new FileUtil(); testUtil.createDirectory(directory); // temporary path that the file will start in and then move it into the folder File folderFile = testUtil.creatFile(directory, "inFolderFile", "Hello - This is text in a file that is going to be deleted"); DefaultFileInfo myFileInfo = infoCurrent.createFileInfo(folderFile, "myFile"); myFileInfo.setId(1l); String endPath = properties.getProperty("FileSystemManagerTest.move.final"); DefaultFileDatabase fd2 = server.createFileDatabase("displayName12", "fileDB_12", endPath, "description"); TreeFolderInfo infoDest = FileSystemManager.createFolder("end1", fd2); File oldLocation = new File(infoCurrent.getFullPath()); assert oldLocation.exists() : "Folder " + oldLocation.getAbsolutePath() + " should exist"; infoDest.addChild(infoCurrent); assert !oldLocation.exists() : " Folder " + oldLocation.getAbsolutePath() + " should no longer exist"; String correctFolderName = FilenameUtils .separatorsToSystem(infoDest.getFullPath() + "start1" + IOUtils.DIR_SEPARATOR); assert infoCurrent.getFullPath().equals(correctFolderName) : "New path should equal " + correctFolderName + " but " + "equals " + infoCurrent.getFullPath(); assert infoCurrent.getFiles().size() == 1 : "Info Dest should have one child but has " + infoDest.getFiles().size(); DefaultFileInfo childFile = infoCurrent.getFileInfo(1L); assert childFile != null : "Child should not be null"; String nameToEqual = FilenameUtils.separatorsToSystem(infoCurrent.getFullPath() + childFile.getName()); assert childFile.getFullPath().equals(nameToEqual) : "File name should equal " + nameToEqual + " but " + " = " + childFile.getFullPath(); assert FileSystemManager.deleteFolder(infoDest) : "Folder Path should be deleted"; assert FileSystemManager.deleteFolder(infoCurrent) : "Folder Path should be deleted"; assert FileSystemManager.deleteDirectory(fd.getFullPath()); assert FileSystemManager.deleteDirectory(fd2.getFullPath()); }
From source file:com.orient.lib.xbmc.addons.Addon.java
boolean loadSettings(boolean bForce /* = false */) { if (settingsLoaded && !bForce) return true; // if (!hasSettings) // return false; String addonFileName = FilenameUtils.separatorsToSystem(props.path + "/resources/settings.xml"); if (addonXmlDoc == null) addonXmlDoc = XMLUtils.getDocument(addonFileName); if (addonXmlDoc == null) { hasSettings = false;/*from w ww .j av a2 s . c o m*/ return false; } // Make sure that the addon XML has the settings element Element settings = addonXmlDoc.getDocumentElement(); if (settings == null || !settings.getNodeName().equals("settings")) { return false; } settingsFromXML(addonXmlDoc, true); // LoadUserSettings(); settingsLoaded = true; return true; }
From source file:edu.ur.file.db.DefaultFileDatabase.java
/** * Set the path of the folder. This makes no changes to the children * folders. The path must be a full path and cannot be relative. The path * must also include the prefix i.e. C:/ (for windows) or / (for unix). * /* ww w.j a va2s . com*/ * * This converts the paths to the correct path immediately / for *NIX and \ * for windows. * * @param path */ void setPath(String path) { path = FilenameUtils.separatorsToSystem(path.trim()); // add the end separator if (path.charAt(path.length() - 1) != IOUtils.DIR_SEPARATOR) { path = path + IOUtils.DIR_SEPARATOR; } // get the prefix prefix = FilenameUtils.getPrefix(path).trim(); // the prefix cannot be null. if (prefix == null || prefix.equals("")) { throw new IllegalArgumentException("Path must have a prefix"); } this.path = FilenameUtils.getPath(path); }
From source file:com.silverpeas.attachment.servlets.DragAndDrop.java
private String saveFileOnDisk(FileItem item, String componentId, String context) throws Exception { String fileName = item.getName(); if (fileName != null) { fileName = FilenameUtils.separatorsToSystem(fileName); SilverTrace.info("attachment", "DragAndDrop.doPost", "root.MSG_GEN_PARAM_VALUE", "file = " + fileName); String type = FileRepositoryManager.getFileExtension(fileName); String physicalName = new Date().getTime() + "." + type; File file = new File(AttachmentController.createPath(componentId, context) + physicalName); item.write(file);/*w w w .j ava 2s. c om*/ return physicalName; } return null; }