當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。