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


Java FileUtils.forceMkdir方法代碼示例

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


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

示例1: prepare

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
public void prepare() throws Exception {
    this.funnyCreator.info("Extracting maven");
    ZipUtils.unzipResource("/apache-maven-3.5.0.zip", FunnyConstants.MAVEN_DIRECTORY.getPath());

    this.invoker = new DefaultInvoker();
    this.invoker.setMavenHome(FunnyConstants.MAVEN_DIRECTORY);

    if (!FunnyConstants.BUILD_DIRECTORY.exists()) {
        FileUtils.forceMkdir(FunnyConstants.BUILD_DIRECTORY);
    }

    FunnyCreator.getLogger().info("Parse pom.xml");

    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();

    Document doc = dBuilder.parse(new File(FunnyConstants.REPOSITORY_DIRECTORY, "pom.xml"));
    doc.getDocumentElement().normalize();

    this.projectElement = (Element) doc.getElementsByTagName("project").item(0);
}
 
開發者ID:FunnyGuilds,項目名稱:FunnyCreator,代碼行數:22,代碼來源:FunnyMaven.java

示例2: receiveUpload

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
@Override
public OutputStream receiveUpload(String filename, String mimeType) {
    if (filename == null || filename.isEmpty()) {
        return null;
    }
    log.info("Start uploading file: " + filename);
    try {
        if (validateFileExtension(filename)) {
            this.uploadPath = getTemporaryUploadPath();
            File uploadDirectory = new File(this.uploadPath);
            if (!uploadDirectory.exists()) {
                FileUtils.forceMkdir(uploadDirectory);
            }
            this.file = new File(this.uploadPath + filename);
            return new FileOutputStream(this.file);
        }

    } catch (Exception e) {
        log.error("Error opening file: " + filename, e);
        ViewUtil.iscNotification(VmidcMessages.getString(VmidcMessages_.UPLOAD_COMMON_ERROR) + e.getMessage(),
                Notification.Type.ERROR_MESSAGE);
    }
    return null;
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:25,代碼來源:PluginUploader.java

示例3: resolveUrlBasedMetadataResource

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
private void resolveUrlBasedMetadataResource(final SamlRegisteredService service,
                                             final List<MetadataResolver> metadataResolvers,
                                             final AbstractResource metadataResource) throws Exception {

    final SamlIdPProperties.Metadata md = casProperties.getAuthn().getSamlIdp().getMetadata();
    final File backupDirectory = new File(md.getLocation().getFile(), "metadata-backups");
    final File backupFile = new File(backupDirectory, metadataResource.getFilename());

    LOGGER.debug("Metadata backup directory is designated to be [{}]", backupDirectory.getCanonicalPath());
    FileUtils.forceMkdir(backupDirectory);

    LOGGER.debug("Metadata backup file will be at [{}]", backupFile.getCanonicalPath());
    FileUtils.forceMkdirParent(backupFile);

    final HttpClientMultithreadedDownloader downloader =
            new HttpClientMultithreadedDownloader(metadataResource, backupFile);

    final FileBackedHTTPMetadataResolver metadataProvider = new FileBackedHTTPMetadataResolver(
            this.httpClient.getWrappedHttpClient(), metadataResource.getURL().toExternalForm(),
            backupFile.getCanonicalPath());
    buildSingleMetadataResolver(metadataProvider, service);
    metadataResolvers.add(metadataProvider);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:24,代碼來源:ChainingMetadataResolverCacheLoader.java

示例4: executeScript

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
@Override
public void executeScript(final IScriptTaskEngine engine) {
    try {
        final String folderName = UNIQUE_NAME_GENERATOR.get("conversion");
        final File folder = new File(BASE_FOLDER, folderName);
        FileUtils.forceMkdir(folder);
        final File inputFile = new File(folder, "input.m");
        final FileOutputStream fis = new FileOutputStream(inputFile);
        IOUtils.copy(mfileIn, fis);
        fis.close();
        engine.eval("mfile2sci(\"" + inputFile.getAbsolutePath() + "\", \"" + folder.getAbsolutePath()
                + "\", %f, %T, 1, %T)");
        final File outputFile = new File(folder, "input.sci");
        outputStr = FileUtils.readFileToString(outputFile, Charset.defaultCharset());
        FileUtils.deleteQuietly(folder);
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:subes,項目名稱:invesdwin-context-matlab,代碼行數:20,代碼來源:MFileToSciScriptTask.java

示例5: generateFile

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
/**
 * Write java string to file , Preparing to compile
 *
 * @param java
 * @return
 * @throws IOException
 */
private File generateFile(String fileName, String java) throws IOException {
    logger.info("Step 2:Write java string to file...");
    String floder = TARGETCLASSDIR + FileSeparator + "tmp";
    File destFile = new File(floder);
    FileUtils.forceMkdir(destFile);
    File file = new File(floder + FileSeparator + fileName + ".java");
    try {
        OutputStream outputStream = new FileOutputStream(file);
        outputStream.write(java.getBytes());
        outputStream.flush();
        outputStream.close();
    } catch (IOException e) {
        logger.error(
                "Write java strng to file fail.....message is {}",
                e.getMessage()
        );
        e.printStackTrace();
    }
    return file;
}
 
開發者ID:ShawnShoper,項目名稱:x-job,代碼行數:28,代碼來源:ClassLoaderHandler.java

示例6: JavasciScriptTaskEngineMatlab

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
public JavasciScriptTaskEngineMatlab(final Scilab scilab) {
    this.scilab = scilab;
    this.inputs = new JavasciScriptTaskInputsMatlab(this);
    this.results = new JavasciScriptTaskResultsMatlab(this);
    if (IScriptTaskRunnerMatlab.LOG.isDebugEnabled()) {
        expressionEnding = ";";
    } else {
        expressionEnding = "";
    }
    try {
        FileUtils.forceMkdir(FOLDER);
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
    this.scriptFile = new File(FOLDER, UNIQUE_NAME_GENERATOR.get("script") + ".sce");
}
 
開發者ID:subes,項目名稱:invesdwin-context-matlab,代碼行數:17,代碼來源:JavasciScriptTaskEngineMatlab.java

示例7: StorageService

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
@Autowired
public StorageService(AmazonS3 s3Client) throws IOException {
    isLocalFileSystem = s3Client == null;

    if (isLocalFileSystem) {
        this.s3Client = null;
        this.buckets = null;
        localFileSystemDirectory =
                new File(String.format("%s/%s", new File("build").getAbsolutePath(), "storage"));
        FileUtils.forceMkdir(localFileSystemDirectory);
    } else {
        this.s3Client = s3Client;
        this.buckets = new ConcurrentHashMap<>();
        this.s3Client.listBuckets().forEach(bucket -> buckets.put(bucket.getName(), bucket));
    }
}
 
開發者ID:bigbug-studio,項目名稱:generator-jhipster-storage,代碼行數:17,代碼來源:_StorageService.java

示例8: checkFiles

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
private static void checkFiles(Guild g) {
	File f;
	if (!(f = new File("resources/guilds/" + g.getId() +"/")).exists()) {
		try {
			FileUtils.forceMkdir(f);
			FileUtils.copyFile(new File("resources/guilds/template.properties"), 
					new File("resources/guilds/" + g.getId() + "/GuildProperties.properties"));
			FileUtils.copyFile(new File("resources/guilds/template.db"), 
					new File("resources/guilds/" + g.getId() + "/Data.db"));
			FileUtils.copyFile(new File("resources/guilds/template.json"), 
					new File("resources/guilds/" + g.getId() + "/IdlePlaylist.json"));
			log.info("Guild file initialized: {}", g.getId());
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	}
}
 
開發者ID:paul-io,項目名稱:momo-2,代碼行數:18,代碼來源:Listeners.java

示例9: setExtendsDir

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
public void setExtendsDir(String extendsDir) {
    this.extendsDir = extendsDir;

    File dir = new File(extendsDir);
    if (!dir.exists()) {
        try {
            FileUtils.forceMkdir(dir);
        } catch (IOException e) {
            logger.error("##ERROR", e);
        }
    }
}
 
開發者ID:luoyaogui,項目名稱:otter-G,代碼行數:13,代碼來源:FileSystemClassScanner.java

示例10: setup

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
@Before
public void setup() throws IOException {
    initMocks(this);
    FileUtils.forceMkdir(new File(ApplicationProperties.get(PropertyKeys.PATHS_GENERATED_RESOURCE_DIR) + "/" + JUNIT_JVM));

    reset(Config.mockJvmPersistenceService, Config.mockGroupService, Config.mockApplicationService, Config.mockHistoryFacadeService,
            Config.mockMessagingTemplate, Config.mockGroupStateNotificationService, Config.mockResourceService,
            Config.mockClientFactoryHelper, Config.mockJvmControlService, Config.mockBinaryDistributionService,
            Config.mockBinaryDistributionLockManager, Config.mockJvmStateService, Config.mockWebServerPersistenceService, Config.mockGroupPersistenceService);
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:11,代碼來源:JvmServiceImplTest.java

示例11: initOutPutPath

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
public static void initOutPutPath(String outputPath) {
	HardcodedData.outputTablesPath = outputPath;
	try {
		FileUtils.forceMkdir(new File(HardcodedData.outputTablesPath));
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
開發者ID:smart-facility,項目名稱:calendar-based-microsim,代碼行數:10,代碼來源:HardcodedData.java

示例12: createPid

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
public static String createPid( String pidDir) throws Exception
{
	if ( !PathUtils.exists_file(pidDir) )
	{
		FileUtils.forceMkdir(new File(pidDir));
	}
	if (! new File(pidDir).isDirectory() )
	{
		throw new RuntimeException("pid dir: " + pidDir + "is not directory.");
	}
	List<String> existPids = PathUtils.read_dir_contents(pidDir);
	//獲得當前進程ID
	String pid = process_pid();
	String pidPath = pidDir + Config.FILE_SEPERATEOR + pid;
	PathUtils.touch(pidPath);
	LOG.info("Successfully touch pid: " + pidPath );

	for (String existPid : existPids)
	{
		try
		{
			kill(Integer.valueOf(existPid));
			PathUtils.rmpath(pidDir + Config.FILE_SEPERATEOR + existPid);
		} catch (Exception e)
		{
			LOG.warn(e.getMessage(),e);
		}
	}
	return pidPath;

}
 
開發者ID:weizhenyi,項目名稱:leaf-snowflake,代碼行數:32,代碼來源:Utils.java

示例13: writeAvroSchema

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
private void writeAvroSchema(final Schema schema) throws IOException {
  // Generate schema in JAR output directory.
  final File schemaFile = new File(options.getJarOutputDir(), schema.getName() + ".avsc");

  LOG.info("Writing Avro schema file: " + schemaFile);
  FileUtils.forceMkdir(schemaFile.getParentFile());
  FileUtils.writeStringToFile(schemaFile, schema.toString(true));

  // Copy schema to code output directory.
  try {
    FileUtils.moveFileToDirectory(schemaFile, new File(options.getCodeOutputDir()), true);
  } catch (final IOException e) {
    LOG.debug("Could not move Avro schema file to code output directory.", e);
  }
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:16,代碼來源:DataDrivenImportJob.java

示例14: makeDirectory

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
public static void makeDirectory(String directory) throws Exception {
	File dir = new File(directory);
	if (!dir.exists()) {
		try {
			FileUtils.forceMkdir(dir);
		} catch (SecurityException se) {
			// handle it
		}

		if (!dir.exists())
			throw new Exception("Unable to create directory - " + directory);
	}
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:14,代碼來源:FileUtility.java

示例15: getCache

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
private File getCache() throws IOException {
    if (StringUtils.isEmpty(cacheFolder)) {
        return null;
    }
    File cacheDirectory = new File(cacheFolder);
    FileUtils.forceMkdir(cacheDirectory);
    return cacheDirectory;
}
 
開發者ID:GoldRenard,項目名稱:JuniperBotJ,代碼行數:9,代碼來源:BlurImageController.java


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