当前位置: 首页>>代码示例>>Java>>正文


Java FilenameUtils.normalize方法代码示例

本文整理汇总了Java中org.apache.commons.io.FilenameUtils.normalize方法的典型用法代码示例。如果您正苦于以下问题:Java FilenameUtils.normalize方法的具体用法?Java FilenameUtils.normalize怎么用?Java FilenameUtils.normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.io.FilenameUtils的用法示例。


在下文中一共展示了FilenameUtils.normalize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ensureFileInContentStore

import org.apache.commons.io.FilenameUtils; //导入方法依赖的package包/类
private void ensureFileInContentStore(File file)
{
    String fileNormalizedAbsoultePath = FilenameUtils.normalize(file.getAbsolutePath());
    String rootNormalizedAbsolutePath = FilenameUtils.normalize(rootAbsolutePath);
    
    if (!fileNormalizedAbsoultePath.startsWith(rootNormalizedAbsolutePath))
    {
        throw new ContentIOException("Access to files outside of content store root is not allowed: " + file);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:FileContentStore.java

示例2: doPost

import org.apache.commons.io.FilenameUtils; //导入方法依赖的package包/类
/**
 * @see HttpServlet#doPut(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	// Check if it is LSP registration
	String lspReg = request.getHeader("Register-lsp");
	if ( lspReg != null ) {
		handleLSPDest(Boolean.parseBoolean(lspReg), request.getReader());
		return;
	}

	// Otherwise process data passed from DI
	if( !checkSync() ) {
		response.setStatus(HttpServletResponse.SC_NO_CONTENT);
		return;
	}
	String artifactRelPath = request.getRequestURI().substring(request.getServletPath().length() + 1);
	String artifactPath = this.saveDir + artifactRelPath;

	File destination = new File(FilenameUtils.normalize(artifactPath));
	// Expected: one part containing zip
	try{
		Part part = request.getParts().iterator().next();

		WSChangeObserver changeObserver = new WSChangeObserver(ChangeType.CHANGE_UPDATED, lspDestPath);
		if (destination.exists() && !destination.isDirectory() && extract(part.getInputStream(), changeObserver)) {
			changeObserver.notifyLSP();
			response.setContentType("application/json");
			response.getWriter().append(String.format("{ \"updated\": \"%s\"}", artifactRelPath));
			response.setStatus(HttpServletResponse.SC_OK);
		} else {
			response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
		}
	} catch (NoSuchElementException ePart) {
		response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
	}
}
 
开发者ID:SAP,项目名称:cloud-language-servers-container,代码行数:38,代码来源:WSSynchronization.java

示例3: addNewFiles

import org.apache.commons.io.FilenameUtils; //导入方法依赖的package包/类
private void addNewFiles(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
	String artifactRelPath;
	artifactRelPath = request.getRequestURI().substring(request.getServletPath().length() + 1 );
	File destination = new File(FilenameUtils.normalize(this.saveDir + artifactRelPath));
	if (destination.exists()) {
		LOG.info("File to be added already exist: " + destination.getPath());
		response.setContentType("application/json");
		response.getWriter().append(String.format("{ \"error\": \"already exists %s\"}", destination.getPath()));
		response.setStatus(HttpServletResponse.SC_FORBIDDEN);
		return;
	}
	// Expected: one part containing zip
	try{
		Part part = request.getParts().iterator().next();
		WSChangeObserver changeObserver = new WSChangeObserver(ChangeType.CHANGE_CREATED, lspDestPath);
		if (extract(part.getInputStream(), changeObserver)) {
			changeObserver.notifyLSP();
			response.setContentType("application/json");
			response.getWriter().append(String.format("{ \"created\": \"%s\"}", artifactRelPath));
			response.setStatus(HttpServletResponse.SC_CREATED);
		} else {
			response.setContentType("application/json");
			response.getWriter().append(String.format("{ \"error\": \"conflict %s\"}", artifactRelPath));
			response.setStatus(HttpServletResponse.SC_CONFLICT);
		}
	} catch (NoSuchElementException ePart) {
		response.setContentType("application/json");
		response.getWriter().append(String.format("{ \"error\": \"exception for %s\"}", artifactRelPath));
		response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
	}
}
 
开发者ID:SAP,项目名称:cloud-language-servers-container,代码行数:32,代码来源:WSSynchronization.java

示例4: setupJaasConfigEntries

import org.apache.commons.io.FilenameUtils; //导入方法依赖的package包/类
private static void setupJaasConfigEntries(String hostServerPrincipal,
        String hostLearnerPrincipal, String hostNamedLearnerPrincipal) {
    String keytabFilePath = FilenameUtils.normalize(KerberosTestUtils.getKeytabFile(), true);
    String jaasEntries = new String(""
            + "QuorumServer {\n"
            + "       com.sun.security.auth.module.Krb5LoginModule required\n"
            + "       useKeyTab=true\n"
            + "       keyTab=\"" + keytabFilePath + "\"\n"
            + "       storeKey=true\n"
            + "       useTicketCache=false\n"
            + "       debug=true\n"
            + "       doNotPrompt=true\n"
            + "       refreshKrb5Config=true\n"
            + "       principal=\"" + KerberosTestUtils.replaceHostPattern(hostServerPrincipal) + "\";\n" + "};\n"
            + "QuorumLearner {\n"
            + "       com.sun.security.auth.module.Krb5LoginModule required\n"
            + "       useKeyTab=true\n"
            + "       keyTab=\"" + keytabFilePath + "\"\n"
            + "       storeKey=true\n"
            + "       useTicketCache=false\n"
            + "       debug=true\n"
            + "       doNotPrompt=true\n"
            + "       refreshKrb5Config=true\n"
            + "       isInitiator=true\n"
            + "       principal=\"" + KerberosTestUtils.replaceHostPattern(hostLearnerPrincipal) + "\";\n" + "};\n"
            + "QuorumLearnerMyHost {\n"
            + "       com.sun.security.auth.module.Krb5LoginModule required\n"
            + "       useKeyTab=true\n"
            + "       keyTab=\"" + keytabFilePath + "\"\n"
            + "       storeKey=true\n"
            + "       useTicketCache=false\n"
            + "       debug=true\n"
            + "       doNotPrompt=true\n"
            + "       refreshKrb5Config=true\n"
            + "       isInitiator=true\n"
            + "       principal=\"" + hostNamedLearnerPrincipal + "\";\n" + "};\n");
    setupJaasConfig(jaasEntries);
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:39,代码来源:QuorumKerberosHostBasedAuthTest.java

示例5: normalize

import org.apache.commons.io.FilenameUtils; //导入方法依赖的package包/类
private static File normalize(File file) {
    String path = file.getAbsolutePath();
    return new File(FilenameUtils.normalize(path));
}
 
开发者ID:intuit,项目名称:karate,代码行数:5,代码来源:FeatureBrowsePanel.java

示例6: loadFile

import org.apache.commons.io.FilenameUtils; //导入方法依赖的package包/类
protected Collection<File> loadFile(FhirContext theCtx, String theSpecUrl, String theFilepath, boolean theCacheFile) throws IOException {
	String userHomeDir = System.getProperty("user.home");

	File applicationDir = new File(userHomeDir + File.separator + "." + "hapi-fhir-cli");
	FileUtils.forceMkdir(applicationDir);

	Collection<File> inputFiles;
	if (isNotBlank(theFilepath)) {
		ourLog.info("Loading from local path: {}", theFilepath);

		if (theFilepath.startsWith("~" + File.separator)) {
			theFilepath = userHomeDir + theFilepath.substring(1);
		}

		File suppliedFile = new File(FilenameUtils.normalize(theFilepath));

		if (suppliedFile.isDirectory()) {
			inputFiles = FileUtils.listFiles(suppliedFile, new String[]{"zip"}, false);
		} else {
			inputFiles = Collections.singletonList(suppliedFile);
		}

	} else {

		File cacheDir = new File(applicationDir, "cache");
		FileUtils.forceMkdir(cacheDir);

		File inputFile = new File(cacheDir, "examples-json-" + theCtx.getVersion().getVersion() + ".zip");

		Date cacheExpiryDate = DateUtils.addHours(new Date(), -12);

		if (!inputFile.exists() | (theCacheFile && FileUtils.isFileOlder(inputFile, cacheExpiryDate))) {

			File exampleFileDownloading = new File(cacheDir, "examples-json-" + theCtx.getVersion().getVersion() + ".zip.partial");

			HttpGet get = new HttpGet(theSpecUrl);
			CloseableHttpClient client = HttpClientBuilder.create().build();
			CloseableHttpResponse result = client.execute(get);

			if (result.getStatusLine().getStatusCode() != 200) {
				throw new CommandFailureException("Got HTTP " + result.getStatusLine().getStatusCode() + " response code loading " + theSpecUrl);
			}

			ourLog.info("Downloading from remote url: {}", theSpecUrl);
			downloadFileFromInternet(result, exampleFileDownloading);

			FileUtils.deleteQuietly(inputFile);
			FileUtils.moveFile(exampleFileDownloading, inputFile);

			if (!theCacheFile) {
				inputFile.deleteOnExit();
			}

			ourLog.info("Successfully Loaded example pack ({})", FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(inputFile)));
			IOUtils.closeQuietly(result.getEntity().getContent());
		}

		inputFiles = Collections.singletonList(inputFile);

	}
	return inputFiles;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:63,代码来源:BaseCommand.java


注:本文中的org.apache.commons.io.FilenameUtils.normalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。