List of usage examples for org.apache.commons.io FilenameUtils concat
public static String concat(String basePath, String fullFilenameToAdd)
From source file:com.quinsoft.zeidon.standardoe.ApplicationList.java
/** * Loads the list of applications from %ZEIDON%/zeidon.app *//*from w w w .j a v a 2 s . co m*/ ApplicationList(HomeDirectory home, ZeidonLogger logger) { logger.info("Loading application list"); this.home = home; Map<String, ApplicationImpl> apps = new HashMap<String, ApplicationImpl>(); // First try loading the resources. ClassLoader classLoader = getClass().getClassLoader(); if (classLoader == null) classLoader = ClassLoader.getSystemClassLoader(); try { for (Enumeration<URL> element = classLoader.getResources("zeidon.app"); element.hasMoreElements();) { URL url = element.nextElement(); logger.info("Loading applications from resource %s", url.getFile()); InputStream stream = url.openStream(); ApplicationHandler appHandler = new ApplicationHandler(apps); PortableFileReader.ReadPortableFile(stream, logger, appHandler); } } catch (Exception e) { throw ZeidonException.wrapException(e).appendMessage("Error while attempting to load zeidon.app"); } if (!StringUtils.isBlank(home.getHomeDirectory())) { String filename = FilenameUtils.concat(home.getHomeDirectory(), "zeidon.app"); try { InputStream inputStream = JoeUtils.getInputStream(null, filename, logger.getClass().getClassLoader()); if (inputStream == null) logger.info("No zeidon.app found via ZEIDON_HOME."); else { logger.info("Loading apps using ZEIDON_HOME (%s)/zeidon.app", home.getHomeDirectory()); ApplicationHandler appHandler = new ApplicationHandler(apps); PortableFileReader.ReadPortableFile(inputStream, logger, appHandler); } } catch (Exception e) { throw ZeidonException.wrapException(e).prependFilename(filename); } } if (apps.size() == 0) throw new ZeidonException("No resources named zeidon.app found."); applications = ImmutableMap.copyOf(apps); }
From source file:de.tor.tribes.util.AttackToTextWriter.java
private static boolean writeBlocksToZip(List<String> pBlocks, Tribe pTribe, File pPath) { int fileNo = 1; String baseFilename = pTribe.getName().replaceAll("\\W+", ""); ZipOutputStream zout = null;//from ww w . j a v a 2s. c om try { zout = new ZipOutputStream( new FileOutputStream(FilenameUtils.concat(pPath.getPath(), baseFilename + ".zip"))); for (String block : pBlocks) { String entryName = baseFilename + fileNo + ".txt"; ZipEntry entry = new ZipEntry(entryName); try { zout.putNextEntry(entry); zout.write(block.getBytes()); zout.closeEntry(); } catch (IOException ioe) { logger.error("Failed to write attack to zipfile", ioe); return false; } fileNo++; } } catch (IOException ioe) { logger.error("Failed to write content to zip file", ioe); return false; } finally { if (zout != null) { try { zout.flush(); zout.close(); } catch (IOException ignored) { } } } return true; }
From source file:au.org.ala.delta.confor.ToIntTest.java
@Test public void zztestPoneriniToInt() throws Exception { File tointDirectory = urlToFile("/dataset/"); File dest = new File(System.getProperty("java.io.tmpdir")); FileUtils.copyDirectory(tointDirectory, dest); String tointFilePath = FilenameUtils.concat(dest.getAbsolutePath(), "ponerini/toint"); CONFOR.main(new String[] { tointFilePath }); File ichars = new File(FilenameUtils.concat(dest.getAbsolutePath(), "ponerini/ichars")); File iitems = new File(FilenameUtils.concat(dest.getAbsolutePath(), "ponerini/iitems")); IntkeyDataset dataSet = IntkeyDatasetFileReader.readDataSet(ichars, iitems); File expectedIChars = new File( FilenameUtils.concat(dest.getAbsolutePath(), "ponerini/expected_results/ichars")); File expectedIItems = new File( FilenameUtils.concat(dest.getAbsolutePath(), "ponerini/expected_results/iitems")); IntkeyDataset expectedDataSet = IntkeyDatasetFileReader.readDataSet(expectedIChars, expectedIItems); compare(dataSet, expectedDataSet);/* w ww . ja v a2 s. co m*/ }
From source file:com.mbrlabs.mundus.core.AssetManager.java
/** * * @param textureFile/* w ww . ja v a 2 s.co m*/ * @param mipMap * @return */ public MTexture importTexture(FileHandle textureFile, boolean mipMap) { long id = projectManager.current().obtainID(); String relativeImportPath = ProjectManager.PROJECT_TEXTURE_DIR + textureFile.name(); String absoluteImportPath = FilenameUtils.concat(projectManager.current().path, relativeImportPath); FileHandle absoluteImportFile = Gdx.files.absolute(absoluteImportPath); textureFile.copyTo(absoluteImportFile); MTexture tex = new MTexture(); tex.setId(id); tex.setPath(relativeImportPath); if (mipMap) { tex.texture = TextureUtils.loadMipmapTexture(absoluteImportFile, true); } else { tex.texture = new Texture(absoluteImportFile); } projectManager.current().textures.add(tex); // save whole project projectManager.saveCurrentProject(); return tex; }
From source file:io.github.retz.executor.RetzExecutorTest.java
@Test public void launchTaskTest() throws IOException, InterruptedException { assert driver.start() == Protos.Status.DRIVER_RUNNING; // check registered called System.err.println(folder.toString()); String tempFilename = FilenameUtils.concat("/tmp", folder.newFile().getName()); System.err.println("Temporary file: " + tempFilename); assert !new File(tempFilename).exists(); Job job = new Job("appname", "touch " + tempFilename, null, new Range(1, 0), new Range(128, 0)); Application app = new Application("appname", new LinkedList<>(), new LinkedList<>(), Optional.empty()); MetaJob metaJob = new MetaJob(job, app); Protos.TaskInfo task = Protos.TaskInfo.newBuilder() .setTaskId(Protos.TaskID.newBuilder().setValue("foobar-task").build()) .setData(ByteString.copyFromUtf8(mapper.writeValueAsString(metaJob))) .setExecutor(executor.getExecutorInfo()).setSlaveId(executor.getSlaveInfo().getId()) .addAllResources(ResourceConstructor.construct(3, 512)).setName("yeah, holilday!").build(); executor.launchTask(driver, task);/* ww w . j av a 2 s . c o m*/ while (LocalProcessManager.isTaskFinished(task.getTaskId())) { Thread.sleep(512); } assert new File(tempFilename).exists(); assert driver.stop() == Protos.Status.DRIVER_STOPPED; // check shutdown called }
From source file:com.github.technosf.posterer.models.impl.base.AbstractPropertiesModel.java
/** * Default constructor - create the properties directory */// w w w .j a v a 2s . c o m @SuppressWarnings("null") protected AbstractPropertiesModel(final String prefix) { PROPERTIES_DIR = FilenameUtils.concat(getProperty(PROP_USER_HOME), PROPERTIES_SUBDIR); propsDir = new File(PROPERTIES_DIR); if (!propsDir.exists()) { propsDir.mkdir(); } String fileName = PROPERTIES_FILENAME; if (!isWhitespace(prefix)) { fileName = prefix + fileName; } PROPERTIES_FILE = FilenameUtils.concat(PROPERTIES_DIR, fileName); propsFile = new File(PROPERTIES_FILE); }
From source file:edu.cornell.med.icb.goby.counts.TestReadWriteCounts.java
@Test @SuppressWarnings("deprecation") // We are intentionally testing a deprecated method here public void testReadTransitions() throws IOException { final String basename = FilenameUtils.concat(BASE_TEST_DIR, "counts-104.bin"); final CountsWriterI writerI = new CountsWriter(new FileOutputStream(basename), 45); writerI.appendCount(10, 1);/*from ww w. j a v a2s. c om*/ writerI.appendCount(15, 1); writerI.close(); final CountsReader reader = new CountsReader(new FileInputStream(basename)); assertTrue(reader.hasNextTransition()); reader.nextTransition(); assertEquals(0, reader.getPosition()); assertEquals(1, reader.getLength()); assertEquals(10, reader.getCount()); assertEquals(-35, reader.getDeltaCount()); assertTrue(reader.hasNextPosition()); reader.nextTransition(); assertEquals(1, reader.getPosition()); assertEquals(1, reader.getLength()); assertEquals(15, reader.getCount()); assertEquals(5, reader.getDeltaCount()); assertFalse(reader.hasNextTransition()); }
From source file:edu.cornell.med.icb.goby.stats.TestStatsWriter.java
@Test public void testVCFFormat() throws IOException { final String file = FilenameUtils.concat(BASE_TEST_DIR, "format-1.vcf"); VCFWriter writer = new VCFWriter(new PrintWriter(new FileWriter(file))); int fieldC = writer.defineField("FORMAT", "GT", 1, ColumnType.String, "Desc GT"); int fieldD = writer.defineField("FORMAT", "GQ", 1, ColumnType.String, "Desc GQ"); String samples[] = { "sample-id-1", "sample-id-2" }; writer.defineSamples(samples);/*from w ww.j a v a 2 s .c o m*/ writer.writeHeader(); writer.setSampleValue(fieldC, 0, "A"); writer.setSampleValue(fieldD, 0, "B"); writer.setSampleValue(fieldC, 1, "B"); writer.setSampleValue(fieldD, 1, "A"); writer.writeRecord(); writer.close(); assertEquals(new File("test-data/stats-writer/expected-format-1.vcf"), new File("test-results/stats-writer/format-1.vcf")); }
From source file:com.izforge.izpack.util.file.FileUtils.java
/** * Interpret the filename as a file relative to the given file * unless the filename already represents an absolute filename. * * @param file the "reference" file for relative paths. This * instance must be an absolute file and must not contain * "./" or "../" sequences (same for \ instead * of /). If it is null, this call is equivalent to * <code>new java.io.File(filename)</code>. * @param filename a file name.//from w w w .j a v a 2 s. c om * @return an absolute file that doesn't contain "./" or * "../" sequences and uses the correct separator for * the current platform. */ public static File resolveFile(File file, String filename) throws Exception { return new File(FilenameUtils.concat(file == null ? null : file.getPath(), filename)); }
From source file:edu.cornell.med.icb.goby.alignments.TestPositionSlices.java
@Test public void testOneSlice() throws IOException { final String basename = "align-position-slices-1"; buildAlignment(basename);//www . j a va 2 s .c o m {// check that we can read everything only 1 12-13: final AlignmentReader reader = new AlignmentReaderImpl(FilenameUtils.concat(BASE_TEST_DIR, basename), 0, 0, 1, 13); check(reader, 1, 12); check(reader, 1, 13); check(reader, 1, 13); check(reader, 1, 13); assertFalse(reader.hasNext()); reader.close(); } }