List of usage examples for org.apache.commons.io FilenameUtils concat
public static String concat(String basePath, String fullFilenameToAdd)
From source file:com.mbrlabs.mundus.utils.TerrainIO.java
/** * Binary gziped format.//from w ww. jav a2 s. c om * * @param terrain */ public static void exportTerrain(ProjectContext projectContext, Terrain terrain) { float[] data = terrain.heightData; long start = System.currentTimeMillis(); // create file File file = new File(FilenameUtils.concat(projectContext.path, terrain.terraPath)); try { FileUtils.touch(file); } catch (IOException e) { e.printStackTrace(); } // write .terra try (DataOutputStream outputStream = new DataOutputStream( new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file))))) { for (float f : data) { outputStream.writeFloat(f); } outputStream.flush(); } catch (IOException e) { e.printStackTrace(); return; } // write splatmap SplatMap splatmap = terrain.getTerrainTexture().getSplatmap(); if (splatmap != null) { splatmap.savePNG(Gdx.files.absolute(FilenameUtils.concat(projectContext.path, splatmap.getPath()))); } //Log.debug("Terrain export execution time (" + data.length + " floats): " // + (System.currentTimeMillis() - start) + " ms"); }
From source file:com.notes.listen.FsWatchService.java
@Subscribe @AllowConcurrentEvents/*www. j av a 2 s . co m*/ public void proc(PathEvent event) { try { Path path = event.getEventTarget(); String fileName = FilenameUtils.concat("D:\\temp\\", path.toString()); if (fileName.endsWith(".aspx")) { String fullPath = FilenameUtils.getFullPath(fileName); String srcName = FilenameUtils.getBaseName(fileName); } } catch (Error e) { e.printStackTrace(); } }
From source file:au.org.ala.delta.util.FileUtils.java
/** * Checks if a file exists, if so it is backed up using an extension * of ".bak" and the original is deleted. * @param fileName the file name to check (relative). * @param directoryPath the path to the file to check and backup. *///from www .j a va 2 s. co m public static void backupAndDelete(String fileName, String directoryPath) { String fullPath = FilenameUtils.concat(directoryPath, fileName); backupAndDelete(fullPath); }
From source file:io.github.retz.executor.FileManager.java
static void fetchPersistentFiles(List<String> files, String destination, boolean trustPVFiles) throws IOException { for (String file : files) { java.nio.file.Path path = Paths.get(file).getFileName(); if (path == null) { throw new FileSystemException(destination); }/*from w ww . j a va 2 s. c o m*/ File f = new File(FilenameUtils.concat(destination, path.toString())); LOG.info("Downloading: {} as {}", file, f); if (f.exists()) { LOG.debug("File already exists: {}", f); if (!trustPVFiles) { try { boolean needsDecompression = needsDecompression(f, destination); if (needsDecompression) { decompress(f, destination); } else { LOG.info("File {} was correctly decompressed before. Skipping decompression.", file); } } catch (ArchiveException e) { LOG.error("ArchiveException on {}: {}", f, e.getMessage()); e.printStackTrace(); } } } else if (file.startsWith("http")) { fetchHTTPFile(file, destination); decompress(f, destination); } else if (file.startsWith("hdfs://")) { fetchHDFSFile(file, destination); decompress(f, destination); } else if (file.startsWith("maprfs://")) { fetchHDFSFile(file, destination); decompress(f, destination); } else { LOG.error("Invalid URL scheme: {}", file); } } }
From source file:au.org.ala.delta.confor.ToPayneTest.java
@Test public void testSampleToPayne() throws Exception { runConfor();/*from w ww . j ava2 s . c o m*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/pydata")); String expected = FileUtils.readFileToString(expectedFile, "utf-8"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "pydata")); String actual = FileUtils.readFileToString(actualFile, "utf-8"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. String heading = "Grass Genera 16.08 22-NOV-11"; // <Date>, eg. 11:32 05-OCT-11 actual = actual.replaceAll("Grass Genera.*[0-9]{2}-[a-zA-Z]{3}-[0-9]{4}", heading); assertEquals(expected.trim(), actual.trim()); }
From source file:au.org.ala.delta.confor.PrintCRTest.java
@Test public void testSamplePrintCR() throws Exception { runConfor();//from w ww. ja v a 2 s. c o m File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/chars.rtf")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "rtf/chars.rtf")); String actual = FileUtils.readFileToString(actualFile, "cp1252"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } assertEquals(expected, actual); }
From source file:au.org.ala.delta.confor.PrintNRTest.java
@Test public void testSamplePrintNR() throws Exception { runConfor();/*from ww w. j av a 2 s. c o m*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/names.rtf")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "rtf/names.rtf")); String actual = FileUtils.readFileToString(actualFile, "cp1252"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } assertEquals(expected, actual); }
From source file:au.org.ala.delta.confor.SummaryTest.java
@Test public void testSampleSummary() throws Exception { runConfor();/*from w w w . j a v a2 s .c o m*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/summary.prt")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "summary.prt")); String actual = FileUtils.readFileToString(actualFile, "cp1252"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. String heading = "Grass Genera 15:43 28-NOV-11"; // <Date>, eg. 11:32 05-OCT-11 actual = actual.replaceAll("Grass Genera.*[0-9]{2}-[a-zA-Z]{3}-[0-9]{4}", heading); for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } //assertEquals(expected.trim(), actual.trim()); }
From source file:au.org.ala.delta.confor.PrintCTest.java
@Test public void testSamplePrintC() throws Exception { runConfor();/*from w ww . j ava2s. c o m*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/printc.prt")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "printc.prt")); String actual = FileUtils.readFileToString(actualFile, "cp1252"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. String heading = "Grass Genera 11:32 05-OCT-11"; // <Date>, eg. 11:32 05-OCT-11 actual = actual.replaceAll("Grass Genera.*[0-9]{2}-[a-zA-Z]{3}-[0-9]{4}", heading); for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } assertEquals(expected.trim(), actual.trim()); }
From source file:au.org.ala.delta.confor.PrintIRTest.java
@Test public void testSamplePrintIR() throws Exception { runConfor();/* w ww .j ava 2 s . c om*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/items.rtf")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "rtf/items.rtf")); String actual = FileUtils.readFileToString(actualFile, "cp1252"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } assertEquals(expected, actual); }