本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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");
}
示例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));
}
}
示例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();
}
}
}
示例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);
}
}
}
示例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);
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}