List of usage examples for org.apache.commons.io FilenameUtils concat
public static String concat(String basePath, String fullFilenameToAdd)
From source file:io.github.retz.web.ClientHelper.java
public static void getWholeBinaryFile(Client c, int id, String path, String output) throws IOException { String fullpath = FilenameUtils.concat(output, FilenameUtils.getName(path)); LOG.info("Saving {} as {}", path, fullpath); try (FileOutputStream out = new FileOutputStream(fullpath)) { c.getBinaryFile(id, path, out);/*from w ww.j av a 2 s .c o m*/ } }
From source file:com.mbrlabs.mundus.core.kryo.KryoManager.java
/** * Saves a scene./*from w ww. j av a 2s. c o m*/ * * @param context * project context of the scene * @param scene * scene to save */ public void saveScene(ProjectContext context, Scene scene) { try { String sceneDir = FilenameUtils.concat(context.path + "/" + ProjectManager.PROJECT_SCENES_DIR, scene.getName() + ProjectManager.PROJECT_SCENE_EXTENSION); Output output = new Output(new FileOutputStream(sceneDir)); SceneDescriptor descriptor = DescriptorConverter.convert(scene); kryo.writeObject(output, descriptor); output.flush(); output.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } }
From source file:edu.udo.scaffoldhunter.model.clustering.evaluation.FileSaverMetaModule.java
/** * Construct and save the OrderedBySubsetSize CSV string / file * //ww w. ja va 2 s . c o m * @param results */ private void saveCSVOrderedBySubsetSize(Collection<EvaluationResult> results) { StringBuilder csvString = new StringBuilder(); // ordered keys of all results TreeSet<String> keys = Sets.newTreeSet(); for (EvaluationResult result : results) { keys.addAll(result.getResults().keySet()); } // create csv header csvString.append("subset size,"); for (String key : keys) { csvString.append(key); csvString.append(","); } csvString.deleteCharAt(csvString.length() - 1); // create csv data & store single result file (not storing // csv file at this point) for (EvaluationResult result : results) { csvString.append(System.getProperty("line.separator").toString()); csvString.append(result.getSubsetSize()); csvString.append(","); for (String key : keys) { String value = result.getResults().get(key); if (value != null) { csvString.append(value); } csvString.append(","); } csvString.deleteCharAt(csvString.length() - 1); } saveToFile( FilenameUtils.concat(FilenameUtils.getFullPathNoEndSeparator(path), FilenameUtils.getBaseName(path)) + FilenameUtils.EXTENSION_SEPARATOR + "csv", csvString.toString()); }
From source file:edu.kit.dama.util.SystemUtils.java
/** * Generate the lock script for Unix systems. * * @return The full path to the lock script. * * @throws IOException If the generation fails. *//*from www.ja va 2 s. c o m*/ private static String generateLockScript() throws IOException { String scriptFile; FileWriter fout = null; try { scriptFile = FilenameUtils.concat(System.getProperty("java.io.tmpdir"), "lockFolder.sh"); fout = new FileWriter(scriptFile, false); StringBuilder b = new StringBuilder(); b.append("#!/bin/sh\n"); b.append("echo Changing owner of $1 to `whoami`\n"); b.append("chown `whoami` $1 -R\n"); b.append("echo Changing access of $1 to 700\n"); b.append("chmod 700 $1 -R\n"); LOGGER.debug("Writing script data to '{}'", scriptFile); fout.write(b.toString()); fout.flush(); } finally { if (fout != null) { try { fout.close(); } catch (IOException ioe) {//ignore } } } return scriptFile; }
From source file:com.xiaomi.linden.core.search.HotSwapLindenCoreImpl.java
public synchronized LindenCore getLindenCore(String indexName) throws IOException { LindenCore lindenCore = lindenCoreMap.get(indexName); if (lindenCore == null) { lindenCore = new LindenCoreImpl(lindenConfig, indexName); lindenCoreMap.put(indexName, lindenCore); LOGGER.info("Create new Linden core: " + indexName); // current linden core is also in lindenCoreMap if (lindenCoreMap.size() > MAX_NEXT_INDEX_NUM + 1) { List<String> keys = new ArrayList<>(lindenCoreMap.keySet()); String oldestCoreName = null; for (int i = 0; i < keys.size(); ++i) { if (keys.get(i).startsWith(NEXT_INDEX_NAME_PREFIX)) { if (oldestCoreName == null || oldestCoreName.compareTo(keys.get(i)) > 0) { oldestCoreName = keys.get(i); }//from w w w .j a v a2s . c o m } } if (oldestCoreName == null) { throw new IOException("There is no next linden core in the map."); } LindenCore core = lindenCoreMap.remove(oldestCoreName); core.close(); if (lindenConfig.getIndexType() != LindenConfig.IndexType.RAM) { String dir = FilenameUtils.concat(baseIndexDir, oldestCoreName); FileUtils.deleteQuietly(new File(dir)); LOGGER.info("Abandon and delete index: " + oldestCoreName); } } } return lindenCore; }
From source file:com.perceptive.epm.perkolcentral.bl.ImageNowLicenseBL.java
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.SERIALIZABLE, readOnly = true, rollbackFor = ExceptionWrapper.class) public FileInputStream getSysFpFileInputStream(Imagenowlicenses imagenowlicenses) throws ExceptionWrapper { try {//from w w w . ja v a 2 s . co m imagenowlicenses = imageNowLicenseDataAccessor .getAllImageNowLicensesByRequestId(imagenowlicenses.getImageNowLicenseRequestId()); File filePathForThisRequest = new File( FilenameUtils.concat(fileUploadPath, imagenowlicenses.getImageNowLicenseRequestId())); File fileLocation = new File( FilenameUtils.concat(filePathForThisRequest.getAbsolutePath(), imagenowlicenses.getFileName())); return FileUtils.openInputStream(fileLocation); } catch (Exception ex) { throw new ExceptionWrapper(ex); } }
From source file:com.turn.griffin.GriffinModule.java
public String multiConcat(List<String> pathElements) { String fullConcatName = pathElements.get(0); for (String name : pathElements.subList(1, pathElements.size())) { fullConcatName = FilenameUtils.concat(fullConcatName, name); }/*ww w . j a v a2 s . c o m*/ return fullConcatName; }
From source file:m.w.sys.module.FileModule.java
@At("/download/?") @Ok("raw:stream") public void download(Long id, HttpServletResponse rep) { Atta a = fileService.fetch(id);/* w ww . ja v a 2 s . c om*/ File file = new File(FilenameUtils.concat(FileService.UPLOAD_ROOT_DIR, a.getFilePath())); if (a != null && file.exists()) { InputStream fileIn = Streams.fileIn(file); rep.setContentType("application/x-msdownload"); rep.setContentLength(a.getFileSize().intValue()); String outFileName = Names.encodeFileName(a.getRawName()); rep.setHeader("Content-Disposition", "attachment; filename=".concat(outFileName)); int blockSize = 4096; int totalRead = 0; int readBytes = 0; byte b[] = new byte[blockSize]; try { while ((long) totalRead < a.getFileSize()) { readBytes = fileIn.read(b, 0, blockSize); totalRead += readBytes; rep.getOutputStream().write(b, 0, readBytes); } fileIn.close(); } catch (Exception e) { // ??? } } }
From source file:com.mbrlabs.mundus.Editor.java
private ProjectContext createDefaultProject() { if (registry.getLastOpenedProject() == null || registry.getProjects().size() == 0) { String name = "Default Project"; String path = FileUtils.getUserDirectoryPath(); path = FilenameUtils.concat(path, "MundusProjects"); ProjectContext project = projectManager.createProject(name, path); projectManager.saveProject(project); return project; }//from w ww . j a v a2 s .com return null; }
From source file:edu.cornell.med.icb.goby.alignments.TestPositionSlices.java
private void buildAlignment(String basename) throws IOException { final AlignmentWriterImpl writer = new AlignmentWriterImpl(FilenameUtils.concat(BASE_TEST_DIR, basename)); writer.setNumAlignmentEntriesPerChunk(2); final int numTargets = 3; final int[] targetLengths = new int[numTargets]; for (int referenceIndex = 0; referenceIndex < numTargets; referenceIndex++) { targetLengths[referenceIndex] = 1000; }//from w w w .jav a2s.c om writer.setTargetLengths(targetLengths); // we write this alignment sorted: writer.setSorted(true); int constantQueryLength = 50; // chunk 1: writer.setAlignmentEntry(0, 1, 12, 30, false, constantQueryLength); writer.appendEntry(); writer.setAlignmentEntry(0, 1, 13, 1, false, constantQueryLength); writer.appendEntry(); // chunk 2: writer.setAlignmentEntry(0, 1, 13, 2, false, constantQueryLength); writer.appendEntry(); writer.setAlignmentEntry(0, 1, 13, 3, false, constantQueryLength); writer.appendEntry(); // chunk 3: writer.setAlignmentEntry(0, 2, 123, 30, false, constantQueryLength); writer.appendEntry(); writer.setAlignmentEntry(0, 2, 300, 1, false, constantQueryLength); writer.appendEntry(); // chunk 4: writer.setAlignmentEntry(0, 2, 300, 2, false, constantQueryLength); writer.appendEntry(); writer.close(); writer.printStats(System.out); }