本文整理汇总了Java中org.apache.commons.io.FileUtils.forceMkdirParent方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.forceMkdirParent方法的具体用法?Java FileUtils.forceMkdirParent怎么用?Java FileUtils.forceMkdirParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.FileUtils
的用法示例。
在下文中一共展示了FileUtils.forceMkdirParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: saveObject
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void saveObject(@NonNull final File _portScannerResultFile,
@NonNull final Object _objectToPersist,
@NonNull final List<Class<?>> _asStringClasses) {
try {
FileUtils.forceMkdirParent(_portScannerResultFile);
final boolean success = _portScannerResultFile.createNewFile();
if (!success) {
log.debug("Output file already exists: {}", _portScannerResultFile.getPath());
}
@Cleanup final FileOutputStream fos = new FileOutputStream(_portScannerResultFile);
log.info("Saving file: " + _portScannerResultFile.getPath());
saveCorePlugin.getExtension().save(fos, _objectToPersist, _asStringClasses);
} catch (IOException _e) {
log.error("Failed to save port scan result", _e);
}
}
示例3: takeFullScreenshot
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void takeFullScreenshot(WebDriver webDriver, File pngFile, By... highlights)
throws IOException {
final PageSnapshot pageSnapshot = Shutterbug.shootPage(webDriver, BOTH_DIRECTIONS);
if (ArrayUtils.isNotEmpty(highlights)) {
Arrays.stream(highlights)
.map(webDriver::findElements)
.flatMap(Collection::stream)
.forEach(pageSnapshot::highlight);
}
FileUtils.forceMkdirParent(pngFile);
pageSnapshot.withName(pngFile.getName());
pageSnapshot.save(pngFile.getParent());
FileUtils.deleteQuietly(pngFile);
FileUtils.moveFile(new File(pngFile.getPath() + ".png"), pngFile);
}
示例4: extract
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* Unpack the contents of a tarball (.tar.gz)
*
* @param tarball The source tarbal
*/
public static void extract(File tarball) throws IOException {
TarArchiveInputStream tarIn = new TarArchiveInputStream(
new GzipCompressorInputStream(
new BufferedInputStream(
new FileInputStream(tarball))));
TarArchiveEntry tarEntry = tarIn.getNextTarEntry();
while (tarEntry != null) {
File entryDestination = new File(tarball.getParent(), tarEntry.getName());
FileUtils.forceMkdirParent(entryDestination);
if (tarEntry.isDirectory()) {
FileUtils.forceMkdir(entryDestination);
} else {
entryDestination.createNewFile();
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(entryDestination));
byte[] buffer = new byte[1024];
int len;
while ((len = tarIn.read(buffer)) != -1) {
outputStream.write(buffer, 0, len);
}
outputStream.close();
}
tarEntry = tarIn.getNextTarEntry();
}
tarIn.close();
}
示例5: getObb
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* Check if any OBB files are available, and if so, download and install them. This
* also deletes any obsolete OBB files, per the spec, since there can be only one
* "main" and one "patch" OBB installed at a time.
*
* @see <a href="https://developer.android.com/google/play/expansion-files.html">APK Expansion Files</a>
*/
private void getObb(final String urlString, String obbUrlString,
final File obbDestFile, final String sha256) {
if (obbDestFile == null || obbDestFile.exists() || TextUtils.isEmpty(obbUrlString)) {
return;
}
final BroadcastReceiver downloadReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Downloader.ACTION_STARTED.equals(action)) {
Utils.debugLog(TAG, action + " " + intent);
} else if (Downloader.ACTION_PROGRESS.equals(action)) {
int bytesRead = intent.getIntExtra(Downloader.EXTRA_BYTES_READ, 0);
int totalBytes = intent.getIntExtra(Downloader.EXTRA_TOTAL_BYTES, 0);
appUpdateStatusManager.updateApkProgress(urlString, totalBytes, bytesRead);
} else if (Downloader.ACTION_COMPLETE.equals(action)) {
localBroadcastManager.unregisterReceiver(this);
File localFile = new File(intent.getStringExtra(Downloader.EXTRA_DOWNLOAD_PATH));
Uri localApkUri = Uri.fromFile(localFile);
Utils.debugLog(TAG, "OBB download completed " + intent.getDataString()
+ " to " + localApkUri);
try {
if (Hasher.isFileMatchingHash(localFile, sha256, "SHA-256")) {
Utils.debugLog(TAG, "Installing OBB " + localFile + " to " + obbDestFile);
FileUtils.forceMkdirParent(obbDestFile);
FileUtils.copyFile(localFile, obbDestFile);
FileFilter filter = new WildcardFileFilter(
obbDestFile.getName().substring(0, 4) + "*.obb");
for (File f : obbDestFile.getParentFile().listFiles(filter)) {
if (!f.equals(obbDestFile)) {
Utils.debugLog(TAG, "Deleting obsolete OBB " + f);
FileUtils.deleteQuietly(f);
}
}
} else {
Utils.debugLog(TAG, localFile + " deleted, did not match hash: " + sha256);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
FileUtils.deleteQuietly(localFile);
}
} else if (Downloader.ACTION_INTERRUPTED.equals(action)) {
localBroadcastManager.unregisterReceiver(this);
} else if (Downloader.ACTION_CONNECTION_FAILED.equals(action)) {
DownloaderService.queue(context, urlString, 0, urlString);
} else {
throw new RuntimeException("intent action not handled!");
}
}
};
DownloaderService.queue(this, obbUrlString, 0, obbUrlString);
localBroadcastManager.registerReceiver(downloadReceiver,
DownloaderService.getIntentFilter(obbUrlString));
}