List of usage examples for org.apache.commons.io FilenameUtils concat
public static String concat(String basePath, String fullFilenameToAdd)
From source file:com.enderville.enderinstaller.util.InstallerConfig.java
/** * The folder of optional mods for this installer. * * @return//from w ww . j a va2s. c o m */ public static String getExtraModsFolder() { return FilenameUtils.concat(getInstallerModsFolder(), "extra/"); }
From source file:com.enioka.jqm.api.ServiceSimple.java
@GET @Path("file") @Produces(MediaType.APPLICATION_OCTET_STREAM) public InputStream getDeliverableStream(@QueryParam("id") String randomId) { if (n == null) { throw new ErrorDto("can only retrieve a file when the web app runs on top of JQM", "", 7, Status.BAD_REQUEST);// w ww .java2 s. c om } Deliverable d = null; EntityManager em = null; try { em = ((HibernateClient) JqmClientFactory.getClient()).getEm(); d = em.createQuery("SELECT d from Deliverable d WHERE d.randomId = :ii", Deliverable.class) .setParameter("ii", randomId).getSingleResult(); } catch (NoResultException e) { throw new ErrorDto("Deliverable does not exist", 8, e, Status.BAD_REQUEST); } catch (Exception e) { throw new ErrorDto("Could not retrieve Deliverable metadata from database", 9, e, Status.INTERNAL_SERVER_ERROR); } finally { if (em != null) { em.close(); } } String ext = FilenameUtils.getExtension(d.getOriginalFileName()); res.setHeader("Content-Disposition", "attachment; filename=" + d.getFileFamily() + "." + d.getId() + "." + ext); return getFile(FilenameUtils.concat(n.getDlRepo(), d.getFilePath())); }
From source file:com.xiaomi.linden.client.LindenClient.java
private LindenService.ServiceIface buildClient(String parent, String node) { String nodePath = FilenameUtils.separatorsToUnix(FilenameUtils.concat(parent, node)); byte[] bytes = zkClient.readData(nodePath); ServiceInstance serviceInstance = JSONObject.parseObject(new String(bytes), ServiceInstance.class); String schema = String.format("%s:%s", serviceInstance.getServiceEndpoint().getHost(), serviceInstance.getServiceEndpoint().getPort()); return Thrift.newIface(schema, LindenService.ServiceIface.class); }
From source file:edu.cornell.med.icb.goby.alignments.TestConcatAlignmentReaderWithPerms.java
@Before public void setUp() throws IOException { {/*from w w w .j a va 2s. com*/ outputBasename1 = FilenameUtils.concat(BASE_TEST_DIR, "concat-align-101"); final AlignmentWriterImpl writer = new AlignmentWriterImpl(outputBasename1); writer.setNumAlignmentEntriesPerChunk(1000); writer.setAlignerName("first-aligner"); writer.setAlignerVersion("version-first-aligner"); final int numQuery = 10; int position = 100; final int score = 30; writer.setPermutation(true); for (int targetIndex = 0; targetIndex < numTargets; targetIndex++) { for (int queryIndex = 0; queryIndex < numQuery; queryIndex++) { Alignments.AlignmentEntry.Builder newEntry = Alignments.AlignmentEntry.newBuilder(); newEntry.setQueryIndex(2000 + queryIndex); newEntry.setTargetIndex(targetIndex); newEntry.setScore((float) score); newEntry.setPosition(position++); newEntry.setMatchingReverseStrand(false); newEntry.setMultiplicity(1); newEntry.setQueryLength(constantQueryLength); newEntry.setQueryIndexOccurrences(numTargets); writer.appendEntry(newEntry.build()); numEntriesIn101++; count101++; } } numQueries101 = numQuery; writer.close(); // reads in basename1 hit in 10 different places in the genome. They should be filtered when // removing ambiguous reads. AlignmentTooManyHitsWriter tmhWriter = new AlignmentTooManyHitsWriter(outputBasename1, 2); for (int queryIndex = 0; queryIndex < numQuery; queryIndex++) { tmhWriter.append(queryIndex, 10, 30); } tmhWriter.close(); } { outputBasename2 = FilenameUtils.concat(BASE_TEST_DIR, "concat-align-102"); final AlignmentWriterImpl writer = new AlignmentWriterImpl(outputBasename2); writer.setAlignerName("second-aligner"); writer.setAlignerVersion("version-second-aligner"); writer.setNumAlignmentEntriesPerChunk(1000); writer.setPermutation(true); final int numQuery = 13; int position = 1; final int score = 50; for (int targetIndex = 0; targetIndex < numTargets; targetIndex++) { for (int queryIndex = 0; queryIndex < numQuery; queryIndex++) { Alignments.AlignmentEntry.Builder newEntry = Alignments.AlignmentEntry.newBuilder(); newEntry.setQueryIndex(1000 + queryIndex); newEntry.setTargetIndex(targetIndex); newEntry.setScore((float) score); newEntry.setPosition(position++); newEntry.setMatchingReverseStrand(false); newEntry.setMultiplicity(1); newEntry.setQueryLength(constantQueryLength); newEntry.setQueryIndexOccurrences(numTargets); writer.appendEntry(newEntry.build()); numEntriesIn102++; count102++; } } numQueries102 = numQuery; writer.close(); // reads in basename 2 have just one hit, they are never ambiguous AlignmentTooManyHitsWriter tmhWriter = new AlignmentTooManyHitsWriter(outputBasename2, 2); for (int queryIndex = 0; queryIndex < numQuery; queryIndex++) { tmhWriter.append(queryIndex, 1, 30); } tmhWriter.close(); } }
From source file:es.urjc.mctwp.image.management.ImageCollectionManager.java
/** * It parses and stores temporarily, a list of files. * /*from w w w. j a v a2 s . c om*/ * @param colName * @param files * @throws ImageCollectionException * @throws ImageException * @throws IOException */ public void storeTemporalImages(String colName, List<File> files) throws ImageCollectionException, ImageException, IOException { for (File file : files) { Image image = impm.createImage(file); if (image != null) { if (image instanceof SingleImage) { SingleImage simg = (SingleImage) image; String ext = ImageUtils.getFileExtension(simg.getContent()); File tmpFile = new File(FilenameUtils.concat(sysTempDir.getAbsolutePath(), image.getId() + FilenameUtils.EXTENSION_SEPARATOR_STR + ext)); if (tmpFile.exists()) tmpFile.delete(); FileUtils.copyFile(simg.getContent(), tmpFile); imcc.storeContent(colName, tmpFile, true); tmpFile.delete(); } else { //Create temp directory where put all file content of Image File tmpDir = new File(FilenameUtils.concat(sysTempDir.getAbsolutePath(), image.getId() + FilenameUtils.EXTENSION_SEPARATOR_STR + image.getType())); if (tmpDir.exists()) FileUtils.deleteDirectory(tmpDir); tmpDir.mkdir(); if (image instanceof SeriesImage) { List<Image> images = ((SeriesImage) image).getImages(); if (images != null && !images.isEmpty()) { for (Image img : images) copyToDirectory(tmpDir, img); } } else if (image instanceof ComplexImage) { List<File> auxFiles = ((ComplexImage) image).getContent(); if (auxFiles != null && !auxFiles.isEmpty()) { for (File auxFile : auxFiles) copyToDirectory(tmpDir, auxFile); } } //Store content and delete temporal directory imcc.storeContent(colName, tmpDir, true); FileUtils.deleteDirectory(tmpDir); } } } }
From source file:edu.cornell.med.icb.goby.alignments.TestPositionSlices.java
@Test public void testBeforeSlice() throws IOException { final String basename = "align-position-slices-5"; buildAlignment(basename);//from w ww.j av a2s .com {// check that we can read skipTo before the start of the slice and only get entries that are within the slice // boundaries. final AlignmentReader reader = new AlignmentReaderImpl(FilenameUtils.concat(BASE_TEST_DIR, basename), 2, 300, 2, 300); final Alignments.AlignmentEntry alignmentEntry = reader.skipTo(2, 0); assertNotNull(alignmentEntry); assertEquals(2, alignmentEntry.getTargetIndex()); assertEquals(300, alignmentEntry.getPosition()); check(reader, 2, 300); assertFalse(reader.hasNext()); reader.close(); } }
From source file:edu.cornell.med.icb.goby.alignments.TestIterateSortedAlignment.java
@Test public void testIterateSortedTwoMutations() throws IOException { final String basename = "align-skip-to-1-concat-two-mutations"; final String basenamePath = FilenameUtils.concat(BASE_TEST_DIR, basename); final AlignmentWriterImpl writer = new AlignmentWriterImpl(basenamePath); writer.setNumAlignmentEntriesPerChunk(1); final int numTargets = 3; final int[] targetLengths = new int[numTargets]; for (int referenceIndex = 0; referenceIndex < numTargets; referenceIndex++) { targetLengths[referenceIndex] = 1000; }//from w w w. j av a2 s . c o m writer.setTargetLengths(targetLengths); // we write this alignment sorted: writer.setSorted(true); Alignments.AlignmentEntry.Builder newEntry; newEntry = prepareAlignmentEntry(0, 1, 100, 3, true, new int[] { 2, 31, 34 }, 35); writer.appendEntry(newEntry.build()); writer.close(); writer.printStats(System.out); final IntSet variantReadIndices = new IntOpenHashSet(); final IntSet variantPositionOnRef = new IntOpenHashSet(); IterateSortedAlignmentsListImpl iterator = new IterateSortedAlignmentsListImpl() { public void processPositions(int referenceIndex, int intermediatePosition, DiscoverVariantPositionData positionBaseInfos) { } @Override public void observeVariantBase(ConcatSortedAlignmentReader sortedReaders, Alignments.AlignmentEntry alignmentEntry, Int2ObjectMap<DiscoverVariantPositionData> positionToBases, Alignments.SequenceVariation var, char toChar, char fromChar, byte toQual, int currentReferenceIndex, int currentRefPosition, int currentReadIndex) { variantReadIndices.add(currentReadIndex); variantPositionOnRef.add(currentRefPosition); } }; iterator.iterate(basenamePath); assertTrue(variantReadIndices.contains(34)); assertTrue(variantReadIndices.contains(2)); assertTrue(variantReadIndices.contains(5)); assertTrue(variantPositionOnRef.contains(101)); assertTrue(variantPositionOnRef.contains(130)); assertTrue(variantPositionOnRef.contains(133)); }
From source file:cop.maven.plugins.AbstractRestToRamlMojoTest.java
@Test(groups = "checkOutputDirectoryExists") public void shouldUpdateOutOnceWhenMultipleCheckOutput() throws Exception { File dir = TestUtils.createTempDir(); Build build = new Build(); build.setDirectory(dir.getAbsolutePath()); mojo.project.setBuild(build);/*from w w w . ja v a 2s. c o m*/ mojo.out = "sub"; checkOutputDirectoryExists(mojo); assertThat(mojo.out).isEqualTo(FilenameUtils.concat(dir.getAbsolutePath(), "sub")); checkOutputDirectoryExists(mojo); assertThat(mojo.out).isEqualTo(FilenameUtils.concat(dir.getAbsolutePath(), "sub")); }
From source file:edu.ku.brc.af.core.db.BackupServiceFactory.java
/** * @param restoreName/*from w w w .j a v a 2s .c om*/ * @return */ protected String getStatsName(final String restoreName) { String baseFileName = FilenameUtils.getBaseName(restoreName); String path = FilenameUtils.getFullPath(restoreName); return FilenameUtils.concat(path, baseFileName + ".stats"); }
From source file:com.mbrlabs.mundus.assets.EditorAssetManager.java
public TerrainAsset createTerrainAsset(int vertexResolution, int size) throws IOException { String terraFilename = "terrain_" + UUID.randomUUID().toString() + ".terra"; String metaFilename = terraFilename + ".meta"; // create meta file String metaPath = FilenameUtils.concat(rootFolder.path(), metaFilename); MetaFile meta = createNewMetaFile(new FileHandle(metaPath), AssetType.TERRAIN); meta.setTerrainSize(size);// ww w . ja v a2 s . c om meta.save(); // create terra file String terraPath = FilenameUtils.concat(rootFolder.path(), terraFilename); File terraFile = new File(terraPath); FileUtils.touch(terraFile); // create initial height data float[] data = new float[vertexResolution * vertexResolution]; for (int i = 0; i < data.length; i++) { data[i] = 0; } // write terra file DataOutputStream outputStream = new DataOutputStream( new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(terraFile)))); for (float f : data) { outputStream.writeFloat(f); } outputStream.flush(); outputStream.close(); // load & apply standard chessboard texture TerrainAsset asset = new TerrainAsset(meta, new FileHandle(terraFile)); asset.load(); TextureAsset chessboard = (TextureAsset) findAssetByID(STANDARD_ASSET_TEXTURE_CHESSBOARD); if (chessboard != null) { // create splatmap PixmapTextureAsset splatmap = createPixmapTextureAsset(SplatMap.DEFAULT_SIZE); asset.setSplatmap(splatmap); asset.setSplatBase(chessboard); asset.applyDependencies(); } addAsset(asset); return asset; }