當前位置: 首頁>>代碼示例>>Java>>正文


Java FilenameUtils.concat方法代碼示例

本文整理匯總了Java中org.apache.commons.io.FilenameUtils.concat方法的典型用法代碼示例。如果您正苦於以下問題:Java FilenameUtils.concat方法的具體用法?Java FilenameUtils.concat怎麽用?Java FilenameUtils.concat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.io.FilenameUtils的用法示例。


在下文中一共展示了FilenameUtils.concat方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getOutputFile

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private static File getOutputFile(String extension) {
    outputFilename = args.HasOption("output-file") ? 
            args.GetOption("output-file") : 
            FilenameUtils.getBaseName(args.GetOption("access-file")) + "." + extension;
    
    File outFile = new File(FilenameUtils.concat(FilenameUtils.getFullPath(args.GetOption("access-file")), outputFilename));
    if(outFile.exists()) {
        try {
            outFile.delete();
        } catch(SecurityException e) {
            Error(String.format("Could not delete existing output file '%s'", outputFilename));
            return null;
        }
    }
    
    return outFile;
}
 
開發者ID:clytras,項目名稱:AccessConverter,代碼行數:18,代碼來源:AccessConverter.java

示例2: ClusterConfigurationService

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
public ClusterConfigurationService(Cache cache) throws IOException {
  this.cache = (GemFireCacheImpl) cache;
  Properties properties = cache.getDistributedSystem().getProperties();
  // resolve the cluster config dir
  String clusterConfigRootDir = properties.getProperty(CLUSTER_CONFIGURATION_DIR);

  if (StringUtils.isBlank(clusterConfigRootDir)) {
    clusterConfigRootDir = System.getProperty("user.dir");
  } else {
    File diskDir = new File(clusterConfigRootDir);
    if (!diskDir.exists() && !diskDir.mkdirs()) {
      throw new IOException("Cannot create directory : " + clusterConfigRootDir);
    }
    clusterConfigRootDir = diskDir.getCanonicalPath();
  }

  // resolve the file paths
  String configDiskDirName =
      CLUSTER_CONFIG_DISK_DIR_PREFIX + cache.getDistributedSystem().getName();

  configDirPath = FilenameUtils.concat(clusterConfigRootDir, CLUSTER_CONFIG_ARTIFACTS_DIR_NAME);
  configDiskDirPath = FilenameUtils.concat(clusterConfigRootDir, configDiskDirName);
  sharedConfigLockingService = getSharedConfigLockService(cache.getDistributedSystem());
  status.set(SharedConfigurationStatus.NOT_STARTED);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:26,代碼來源:ClusterConfigurationService.java

示例3: getDataSetIterator

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
public static DataSetIterator getDataSetIterator(String DATA_PATH, boolean isTraining, WordVectors wordVectors, int minibatchSize,
                                                  int maxSentenceLength, Random rng ){
    String path = FilenameUtils.concat(DATA_PATH, (isTraining ? "aclImdb/train/" : "aclImdb/test/"));
    String positiveBaseDir = FilenameUtils.concat(path, "pos");
    String negativeBaseDir = FilenameUtils.concat(path, "neg");

    File filePositive = new File(positiveBaseDir);
    File fileNegative = new File(negativeBaseDir);

    Map<String,List<File>> reviewFilesMap = new HashMap<>();
    reviewFilesMap.put("Positive", Arrays.asList(filePositive.listFiles()));
    reviewFilesMap.put("Negative", Arrays.asList(fileNegative.listFiles()));

    LabeledSentenceProvider sentenceProvider = new FileLabeledSentenceProvider(reviewFilesMap, rng);

    return new CnnSentenceDataSetIterator.Builder()
            .sentenceProvider(sentenceProvider)
            .wordVectors(wordVectors)
            .minibatchSize(minibatchSize)
            .maxSentenceLength(maxSentenceLength)
            .useNormalizedWordVectors(false)
            .build();
}
 
開發者ID:IsaacChanghau,項目名稱:Word2VecfJava,代碼行數:24,代碼來源:CNNSentenceClassification.java

示例4: SentimentExampleIterator

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
/**
 * @param dataDirectory the directory of the IMDB review data set
 * @param wordVectors WordVectors object
 * @param batchSize Size of each minibatch for training
 * @param truncateLength If reviews exceed
 * @param train If true: return the training data. If false: return the testing data.
 */
public SentimentExampleIterator(String dataDirectory, WordVectors wordVectors, int batchSize, int truncateLength, boolean train) throws IOException {
	this.batchSize = batchSize;
	this.vectorSize = wordVectors.getWordVector(wordVectors.vocab().wordAtIndex(0)).length;


	File p = new File(FilenameUtils.concat(dataDirectory, "aclImdb/" + (train ? "train" : "test") + "/pos/") + "/");
	File n = new File(FilenameUtils.concat(dataDirectory, "aclImdb/" + (train ? "train" : "test") + "/neg/") + "/");
	positiveFiles = p.listFiles();
	negativeFiles = n.listFiles();

	this.wordVectors = wordVectors;
	this.truncateLength = truncateLength;

	tokenizerFactory = new DefaultTokenizerFactory();
	tokenizerFactory.setTokenPreProcessor(new CommonPreprocessor());
}
 
開發者ID:IsaacChanghau,項目名稱:NeuralNetworksLite,代碼行數:24,代碼來源:SentimentExampleIterator.java

示例5: getDownloadUrl

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
/**
 * Get a signed url to view an attachment. The url will last 24 hours. The file name portion of the id is url escaped internally.
 *
 * @param id The id of the attachment.
 * @return Url
 */
public String getDownloadUrl(String id) {
    String filename = FilenameUtils.getName(id);
    String path = FilenameUtils.getFullPath(id);
    String escapedFullPath = FilenameUtils.concat(path, UrlEscapers.urlFragmentEscaper().escape(filename));
    return cloudStorage.generateSignedUrl(gcsDefaultBucket, escapedFullPath, DEFAULT_LINK_EXPIRY_DURATION);
}
 
開發者ID:3wks,項目名稱:generator-thundr-gae-react,代碼行數:13,代碼來源:AttachmentService.java

示例6: mkdirForHyperParameterConfig

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
public static void mkdirForHyperParameterConfig() {
    final String homeDir = System.getProperty("user.home");
    final String logDir = "hyper" + new LocalDateTime().toString();
    mHyperParameterConfigDirPath = FilenameUtils.concat(homeDir, logDir);
    try {
        FileUtils.forceMkdir(new File(mHyperParameterConfigDirPath));
    } catch (final IOException e) {
        throw new IllegalStateException(e);
    }
}
 
開發者ID:chncwang,項目名稱:laozhongyi,代碼行數:11,代碼來源:GeneratedFileManager.java

示例7: mkdirForLog

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
public static void mkdirForLog() {
    final String homeDir = System.getProperty("user.home");
    final String logDir = "log" + new LocalDateTime().toString();
    mLogDirPath = FilenameUtils.concat(homeDir, logDir);
    try {
        FileUtils.forceMkdir(new File(mLogDirPath));
    } catch (final IOException e) {
        throw new IllegalStateException(e);
    }
}
 
開發者ID:chncwang,項目名稱:laozhongyi,代碼行數:11,代碼來源:GeneratedFileManager.java

示例8: copyResources

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
protected void copyResources(String baseClassPath, File destDir, String... relativePaths) throws IOException {
    for (String relativePath : relativePaths) {
        String path = FilenameUtils.concat(baseClassPath, relativePath);
        path = path.replace('\\', '/');
        String fileName = path.contains("/") ? StringUtils.substringAfterLast(path, "/") : path;
        copyResource(new ClassPathResource(path), new File(destDir, fileName));
    }
}
 
開發者ID:sdadas,項目名稱:spring2ts,代碼行數:9,代碼來源:BaseClientBuilder.java

示例9: testZipUtils

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
@Test
public void testZipUtils() throws Exception {
  File zipFile = new File(zipFolder, "target.zip");
  assertFalse(zipFile.exists());
  assertFalse(zipFile.isFile());

  ZipUtils.zipDirectory(sourceFolder.getCanonicalPath(), zipFile.getCanonicalPath());
  assertTrue(zipFile.exists());
  assertTrue(zipFile.isFile());

  File destinationFolder = new File(
      FilenameUtils.concat(temporaryFolder.getRoot().getCanonicalPath(), destinationFolderName));
  assertFalse(destinationFolder.exists());
  assertFalse(destinationFolder.isFile());

  ZipUtils.unzip(zipFile.getCanonicalPath(), destinationFolder.getCanonicalPath());
  assertTrue(destinationFolder.exists());
  assertTrue(destinationFolder.isDirectory());

  File[] destinationSubDirs = destinationFolder.listFiles();
  assertNotNull(destinationSubDirs);
  assertEquals(2, destinationSubDirs.length);

  File destinationClusterTextFile =
      new File(FilenameUtils.concat(destinationFolder.getCanonicalPath(),
          clusterFolderName + File.separator + clusterTextFileName));
  assertTrue(destinationClusterTextFile.exists());
  assertTrue(destinationClusterTextFile.isFile());

  File destinationGroupTextFile =
      new File(FilenameUtils.concat(destinationFolder.getCanonicalPath(),
          groupFolderName + File.separator + groupTextFileName));
  assertTrue(destinationGroupTextFile.exists());
  assertTrue(destinationGroupTextFile.isFile());

  assertTrue(clusterText.equals(FileUtils.readFileToString(destinationClusterTextFile)));
  assertTrue(groupText.equals(FileUtils.readFileToString(destinationGroupTextFile)));
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:39,代碼來源:ZipUtilsJUnitTest.java

示例10: absolutePathForFilename

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private String absolutePathForFilename(String filename){
	return FilenameUtils.concat(env.getImageResourceAbsolutePath(), filename);
}
 
開發者ID:GastonMauroDiaz,項目名稱:buenojo,代碼行數:4,代碼來源:ImageResourceService.java

示例11: relativePathForFilename

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private String relativePathForFilename(String filename){
	return FilenameUtils.concat(env.getImageResourceRelativePath(), filename);
}
 
開發者ID:GastonMauroDiaz,項目名稱:buenojo,代碼行數:4,代碼來源:ImageResourceService.java

示例12: loadCurrent

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
/**
 * Loads a PLP6 project. The given file must be a directory, and have a structure as
 * specified by {@link #save()}
 * 
 * @param projectDirectory
 *            The directory of the project to load. This file must be a DIRECTORY, and
 *            have a structure as specified by {@link #save()}
 * @return A {@link PLPProject} representative of the information stored in the given
 *         directory.
 * @throws IOException
 */
private static PLPProject loadCurrent(File projectDirectory) throws IOException
{
	validateProjectDirectory(projectDirectory);
	File projectFile = validateAndFilizeProjectFile(projectDirectory);
	
	if (!projectFile.exists())
		throw new IllegalArgumentException("Project file not found.");
		
	String fileString = FileUtils.readFileToString(projectFile);
	JSONObject projectDetails = new JSONObject(fileString);
	String name = projectDetails.optString(NAME_KEY);
	//String type = projectDetails.optString(NAME_KEY);
	String type = projectDetails.optString(TYPE_KEY);
	String sourceDirectoryName = projectDetails.optString(SOURCE_NAME_KEY, "src");
	String lstAsmFiles = projectDetails.optString(SOURCE_FILES);
	String[] listFiles = lstAsmFiles.split(",");
	
	Path projectPath = projectDirectory.toPath();
	Path sourcePath = projectPath.resolve(sourceDirectoryName);
	File sourceDirectory = sourcePath.toFile();
	
	//PLPProject project = new PLPProject(name, type);
	PLPProject project = new PLPProject(name, type, projectPath.toString());
	
	for (String fileName : listFiles)
	{
		String fullPath = FilenameUtils.concat(sourceDirectory.getAbsolutePath(), fileName);
		String sourceName = FilenameUtils.removeExtension(fileName);
		
		SimpleASMFile sourceFile = new SimpleASMFile(project, fileName, AsmFileContent(fullPath));
		project.add(sourceFile);
	}
	
	/*for (File file : sourceDirectory.listFiles())
	{
		String sourceName = file.getName();
		
		sourceName = FilenameUtils.removeExtension(sourceName);
		
		//While associating asmfile to the project, we need to pass the content of the file also, otherwise when 
		//user tries to open the respective file from project explorer, Editor pane will show empty file - Harsha
		SimpleASMFile sourceFile = new SimpleASMFile(project, sourceName, AsmFileContent(file.getAbsolutePath()));
		//SimpleASMFile sourceFile = new SimpleASMFile(project, sourceName);
		project.add(sourceFile);
	}*/
	
	return project;
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:60,代碼來源:PLPProject.java

示例13: main

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
public static void main (String[] args) throws IOException {
    log.info("download and extract data...");
    CNNSentenceClassification.aclImdbDownloader(DATA_URL, DATA_PATH);

    // basic configuration
    int batchSize = 32;
    int vectorSize = 300;               //Size of the word vectors. 300 in the Google News model
    int nEpochs = 1;                    //Number of epochs (full passes of training data) to train on
    int truncateReviewsToLength = 256;  //Truncate reviews with length (# words) greater than this
    int cnnLayerFeatureMaps = 100;      //Number of feature maps / channels / depth for each CNN layer
    PoolingType globalPoolingType = PoolingType.MAX;
    Random rng = new Random(12345); //For shuffling repeatability

    log.info("construct cnn model...");
    ComputationGraph net = CNNSentenceClassification.buildCNNGraph(vectorSize, cnnLayerFeatureMaps, globalPoolingType);
    log.info("number of parameters by layer:");
    for (Layer l : net.getLayers()) {
        log.info("\t" + l.conf().getLayer().getLayerName() + "\t" + l.numParams());
    }

    // Load word vectors and get the DataSetIterators for training and testing
    log.info("loading word vectors and creating DataSetIterators...");
    WordVectors wordVectors = WordVectorSerializer.loadStaticModel(new File(WORD_VECTORS_PATH));
    DataSetIterator trainIter = CNNSentenceClassification.getDataSetIterator(DATA_PATH, true, wordVectors, batchSize,
            truncateReviewsToLength, rng);
    DataSetIterator testIter = CNNSentenceClassification.getDataSetIterator(DATA_PATH, false, wordVectors, batchSize,
            truncateReviewsToLength, rng);

    log.info("starting training...");
    for (int i = 0; i < nEpochs; i++) {
        net.fit(trainIter);
        log.info("Epoch " + i + " complete. Starting evaluation:");
        //Run evaluation. This is on 25k reviews, so can take some time
        Evaluation evaluation = net.evaluate(testIter);
        log.info(evaluation.stats());
    }

    // after training: load a single sentence and generate a prediction
    String pathFirstNegativeFile = FilenameUtils.concat(DATA_PATH, "aclImdb/test/neg/0_2.txt");
    String contentsFirstNegative = FileUtils.readFileToString(new File(pathFirstNegativeFile));
    INDArray featuresFirstNegative = ((CnnSentenceDataSetIterator)testIter).loadSingleSentence(contentsFirstNegative);
    INDArray predictionsFirstNegative = net.outputSingle(featuresFirstNegative);
    List<String> labels = testIter.getLabels();
    log.info("\n\nPredictions for first negative review:");
    for( int i=0; i<labels.size(); i++ ){
        log.info("P(" + labels.get(i) + ") = " + predictionsFirstNegative.getDouble(i));
    }
}
 
開發者ID:IsaacChanghau,項目名稱:Word2VecfJava,代碼行數:49,代碼來源:DL4JCNNSentClassifyExample.java

示例14: getAbsolutePath

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
private String getAbsolutePath(String relativePath){

		return FilenameUtils.concat(env.getGameResourcesBasePath(), relativePath);
	}
 
開發者ID:GastonMauroDiaz,項目名稱:buenojo,代碼行數:5,代碼來源:ImageResourceService.java

示例15: getImageResourceAbsolutePath

import org.apache.commons.io.FilenameUtils; //導入方法依賴的package包/類
public String getImageResourceAbsolutePath(){
	
	return FilenameUtils.concat(getGameResourcesAbsolutePath(), BuenOjoFileUtils.IMAGE_RESOURCE_DIR);
}
 
開發者ID:GastonMauroDiaz,項目名稱:buenojo,代碼行數:5,代碼來源:BuenOjoEnvironment.java


注:本文中的org.apache.commons.io.FilenameUtils.concat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。