当前位置: 首页>>代码示例>>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;未经允许,请勿转载。