List of usage examples for org.apache.commons.io FilenameUtils separatorsToSystem
public static String separatorsToSystem(String path)
From source file:com.epam.wilma.message.search.web.support.FileZipperTest.java
@Test public void testCreateZipWithFilesWhenFilePathContainsBackSlashes() throws IOException { //GIVEN/*from ww w . j a v a 2s .c o m*/ List<String> pair = new ArrayList<String>(); pair.add(FilenameUtils.separatorsToSystem("src\\test\\resources\\first_testreq.txt")); filePaths.add(pair); //WHEN underTest.createZipWithFiles(filePaths, outputStream); //THEN verify(entryFactory).createZipEntry("first_testreq.txt"); verify(zipOutputStream).putNextEntry(zipEntry); verify(zipOutputStream).close(); }
From source file:com.epam.wilma.stubconfig.cache.cleaner.helper.StubConfigPathProviderTest.java
@Test public void testGetConfigPathsFromSpecificFolderWhenThePatternIsASpecificFileNameAndThisIsInASpecificFolder() { //GIVEN/*from w ww . j a v a 2s .c o m*/ expectedFilePaths = new ArrayList<>(); expectedFilePaths.add(FilenameUtils.separatorsToSystem("test/path/TestPattern")); //WHEN List<String> result = underTest.getConfigPathsFromSpecificFolder("test/path", "TestPattern"); //THEN Assert.assertEquals(result, expectedFilePaths); }
From source file:it.unibas.spicy.persistence.idgenerator.utils.ReadCsv.java
public ArrayList<InputDataModel> readTargetCsv(ArrayList<ColumnMatcherModel> cmmList, String generatedColumn) { ArrayList<InputDataModel> idmList = new ArrayList<>(); try {/*from w ww . jav a 2 s . c o m*/ String[] nextLine; // CSVReader reader = new CSVReader(new FileReader(FilenameUtils.separatorsToSystem(this.path))); Reader r = new FileReader(FilenameUtils.separatorsToSystem(this.path)); CSVReader reader = new CSVReaderBuilder(r).withFieldAsNull(CSVReaderNullFieldIndicator.EMPTY_SEPARATORS) .build(); nextLine = reader.readNext(); ArrayList<Integer> colNums = new ArrayList<>(); ArrayList<String> colName = new ArrayList<>(); for (ColumnMatcherModel cmm : cmmList) { for (int i = 0; i < nextLine.length; i++) { if (nextLine[i].trim().equals(cmm.getTargetColumn().trim())) { colNums.add(i); colName.add(cmm.getTargetColumn().trim()); break; } } } for (int i = 0; i < nextLine.length; i++) { if (nextLine[i].trim().equals(generatedColumn.trim())) { colNums.add(i); colName.add(generatedColumn.trim()); break; } } while ((nextLine = reader.readNext()) != null) { InputDataModel idm = new InputDataModel(); for (int i = 0; i < colNums.size(); i++) { //avenet 20170721 String value; if (nextLine[colNums.get(i)] != null) value = nextLine[colNums.get(i)].trim(); else value = null; idm.addValue(value); idm.addKey(colName.get(i)); } idmList.add(idm); } } catch (IOException e) { System.err.println(e.getMessage()); System.exit(-1); } return idmList; }
From source file:com.orient.lib.xbmc.addons.Addon.java
public String getLibPath() { return FilenameUtils.separatorsToSystem(props.path + "/" + props.libname); }
From source file:com.pieframework.runtime.core.ResourceLoader.java
public static List<File> findPath(String basePath, String query) { List<File> flist = new ArrayList<File>(); if (!StringUtils.empty(basePath, query)) { String root = locate(basePath); query = FilenameUtils.separatorsToSystem(query); query = "*" + query + "*"; //System.out.println(query+" "+root); File rootDir = new File(root); try {//from w ww.ja v a 2s .c o m for (File f : listFilesAndDirectories(rootDir)) { //System.out.println(f.getPath()); if (FilenameUtils.wildcardMatch(f.getPath(), query)) { flist.add(f); } } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return flist; }
From source file:net.erdfelt.android.sdkfido.configer.ConfigCmdLineParserTest.java
@Test public void testSetMultipleOptions() throws CmdLineParseException { 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)); File otherWork = testingdir.getFile("work"); StringWriter capture = new StringWriter(); ConfigCmdLineParser parser = new ConfigCmdLineParser(this, config); parser.setOut(capture);//from ww w . j a v a2 s.co m String[] args = { "--dryRun", "true", "--workDir", otherWork.getAbsolutePath() }; parser.parse(args); Assert.assertThat("Config.dryRun", config.isDryRun(), is(true)); Assert.assertThat("Config.workDir", config.getWorkDir(), is(otherWork)); }
From source file:de.tudarmstadt.ukp.dkpro.keyphrases.bookindexing.evaluation.phrasematch.LineReader.java
private String getPath(String baseName) { return FilenameUtils.separatorsToSystem( FilenameUtils.concat(pathName, baseName) + ((suffix.startsWith(".")) ? suffix : "." + suffix)); }
From source file:com.pieframework.runtime.utils.ArtifactManager.java
private void copy(String download, String filter, String localPath, String virtualPath) { /*System.out.println("download:"+download+ "\nfilter:"+filter+// w w w . j av a2 s .co m "\nlocalPath:"+localPath+ "\nvirtualPath:"+virtualPath); */ boolean match = true; if (!StringUtils.empty(filter)) { match = FilenameUtils.wildcardMatch(FilenameUtils.separatorsToSystem(download), filter); } if (match) { File destinationVirtualFile = new File(FilenameUtils.separatorsToSystem(virtualPath)); File destination = new File(localPath + destinationVirtualFile.getParent()); destination.mkdirs(); if (destination.exists()) { File downloadFile = new File(download); try { FileUtils.copyFileToDirectory(downloadFile, destination); File copiedFile = new File( destination.getPath() + File.separatorChar + destinationVirtualFile.getName()); if (copiedFile.exists()) { System.out.println( "file copied:" + copiedFile + " crc:" + FileUtils.checksumCRC32(copiedFile)); } else { //TODO error } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { //TODO error } } }
From source file:com.ariht.maven.plugins.config.ConfigProcessorMojo.java
/** * Read properties from filter file and substitute template place-holders. * Write results to output path with same relative path as input filters. * * Typical output is to ...target/filter-sub-dir/template-dir/template.name *///from w w w .ja va2 s. c o m private void generateConfig(final FileInfo template, final FileInfo filter, final String outputBasePath) throws IOException, ConfigurationException { final String outputDirectory = createOutputDirectory(template, filter, outputBasePath); final String templateFilename = template.getFile().getName(); final String outputFilename = FilenameUtils.separatorsToSystem(outputDirectory + templateFilename); if (logOutput) { getLog().info("Generating : " + String.valueOf(outputFilename)); } else if (getLog().isDebugEnabled()) { getLog().debug("Generating : " + String.valueOf(outputFilename)); } getLog().debug("Applying filter : " + filter.toString() + " to template : " + template.toString()); final String rawTemplate = FileUtils.readFileToString(template.getFile()); final Properties properties = readFilterIntoProperties(filter); final String processedTemplate = StrSubstitutor.replace(rawTemplate, properties); if (StringUtils.isNotBlank(encoding)) { FileUtils.writeStringToFile(new File(outputFilename), processedTemplate, encoding); } else { FileUtils.writeStringToFile(new File(outputFilename), processedTemplate); } }
From source file:com.pieframework.runtime.core.ResourceLoader.java
public static List<File> findExactPath(File dir, String query) { List<File> flist = new ArrayList<File>(); if (!StringUtils.empty(query) && dir.exists()) { String root = dir.getPath(); query = FilenameUtils.separatorsToSystem(query); String wildCard = "*" + query + "*"; //System.out.println(query+" "+root); File rootDir = new File(root); try {/*from w w w . java 2s. c o m*/ for (File f : listFilesAndDirectories(rootDir)) { //System.out.println(f.getPath()); if (FilenameUtils.wildcardMatch(f.getPath(), wildCard)) { if (f.getName().equals(query)) { flist.add(f); } } } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return flist; }