本文整理汇总了Java中com.intellij.openapi.util.io.FileUtil.createParentDirs方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.createParentDirs方法的具体用法?Java FileUtil.createParentDirs怎么用?Java FileUtil.createParentDirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.io.FileUtil
的用法示例。
在下文中一共展示了FileUtil.createParentDirs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveWhiteList
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static void saveWhiteList(File cachedWhiteList, Map<String, Set<String>> classesWhiteList) {
try {
FileUtil.createParentDirs(cachedWhiteList);
PrintWriter writer = new PrintWriter(cachedWhiteList);
try {
for (String packageName : classesWhiteList.keySet()) {
writer.println("." + packageName);
final Set<String> classes = classesWhiteList.get(packageName);
for (String aClass : classes) {
writer.println(aClass);
}
}
}
finally {
writer.close();
}
}
catch (IOException e) {
LOG.error(e);
}
}
示例2: save
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public synchronized void save() {
try {
FileUtil.createParentDirs(myTargetsFile);
DataOutputStream output = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myTargetsFile)));
try {
output.writeInt(0);
output.writeInt(myTargetIds.size());
for (Map.Entry<BuildTarget<?>, Integer> entry : myTargetIds.entrySet()) {
IOUtil.writeString(entry.getKey().getId(), output);
output.writeInt(entry.getValue());
}
}
finally {
output.close();
}
}
catch (IOException e) {
LOG.info("Cannot save " + myTargetType.getTypeId() + " targets data: " + e.getMessage(), e);
}
}
示例3: save
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void save(CompileContext context) {
try {
File configFile = getConfigFile();
FileUtil.createParentDirs(configFile);
Writer out = new BufferedWriter(new FileWriter(configFile));
try {
String current = getCurrentState(context);
out.write(current);
myConfiguration = current;
}
finally {
out.close();
}
}
catch (IOException e) {
LOG.info("Cannot save configuration of " + myConfiguration, e);
}
}
示例4: test2GLimit
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void test2GLimit() throws IOException {
if (!DO_SLOW_TEST) return;
File file = FileUtil.createTempFile("persistent", "map");
FileUtil.createParentDirs(file);
EnumeratorStringDescriptor stringDescriptor = new EnumeratorStringDescriptor();
PersistentHashMap<String, String> map = null;
try {
map = new PersistentHashMap<String, String>(file, stringDescriptor, stringDescriptor);
for (int i = 0; i < 12000; i++) {
map.put("abc" + i, StringUtil.repeat("0123456789", 10000));
}
map.close();
map = new PersistentHashMap<String, String>(file,
stringDescriptor, stringDescriptor);
long len = 0;
for (String key : map.getAllKeysWithExistingMapping()) {
len += map.get(key).length();
}
assertEquals(1200000000L, len);
}
finally {
clearMap(file, map);
}
}
示例5: ResizeableMappedFile
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public ResizeableMappedFile(@NotNull File file,
int initialSize,
@Nullable PagedFileStorage.StorageLockContext lockContext,
int pageSize,
boolean valuesAreBufferAligned,
boolean nativeBytesOrder) throws IOException {
myStorage = new PagedFileStorage(file, lockContext, pageSize, valuesAreBufferAligned, nativeBytesOrder);
boolean exists = file.exists();
if (!exists || file.length() == 0) {
if (!exists) FileUtil.createParentDirs(file);
writeLength(0);
}
myLogicalSize = readLength();
if (myLogicalSize == 0) {
try {
getPagedFileStorage().lock();
// use direct call to storage.resize() so that IOException is not masked with RuntimeException
myStorage.resize(initialSize);
}
finally {
getPagedFileStorage().unlock();
}
}
}
示例6: extractEntry
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static void extractEntry(ZipEntry entry, final InputStream inputStream, File outputDir, boolean overwrite) throws IOException {
final boolean isDirectory = entry.isDirectory();
final String relativeName = entry.getName();
final File file = new File(outputDir, relativeName);
if (file.exists() && !overwrite) return;
FileUtil.createParentDirs(file);
if (isDirectory) {
file.mkdir();
}
else {
final BufferedInputStream is = new BufferedInputStream(inputStream);
final BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(file));
try {
FileUtil.copy(is, os);
}
finally {
os.close();
is.close();
}
}
}
示例7: saveState
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void saveState(@NotNull MyState state) {
FileUtil.createParentDirs(myFile);
try {
final DataOutputStream output = new DataOutputStream(new FileOutputStream(myFile));
try {
output.writeLong(state.myManifestFileTimestamp);
output.writeInt(state.myLibManifestsTimestamps.size());
for (Object key : state.myLibManifestsTimestamps.keys()) {
final String strKey = (String)key;
output.writeUTF(strKey);
output.writeLong(state.myLibManifestsTimestamps.get(strKey));
}
output.writeBoolean(state.myToMerge);
}
finally {
output.close();
}
}
catch (IOException e) {
LOG.info(e);
}
}
示例8: update
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void update(@Nullable MyState state) {
FileUtil.createParentDirs(myFile);
try {
final DataOutputStream output = new DataOutputStream(new FileOutputStream(myFile));
try {
output.writeBoolean(state != null);
if (state != null) {
output.writeInt(state.myProGuardConfigFiles.size());
for (Map.Entry<String, Long> entry : state.myProGuardConfigFiles.entrySet()) {
final String path = entry.getKey();
final Long timestamp = entry.getValue();
output.writeUTF(path);
output.writeLong(timestamp);
}
}
}
finally {
output.close();
}
}
catch (IOException e) {
LOG.info(e);
}
}
示例9: save
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void save(@NotNull ExternalProject externalProject) {
Output output = null;
try {
final File externalProjectDir = externalProject.getProjectDir();
final File configurationFile =
getProjectConfigurationFile(new ProjectSystemId(externalProject.getExternalSystemId()), externalProjectDir);
if (!FileUtil.createParentDirs(configurationFile)) return;
output = new Output(new FileOutputStream(configurationFile));
myKryo.writeObject(output, externalProject);
LOG.debug("Data saved for imported project from: " + externalProjectDir.getPath());
}
catch (FileNotFoundException e) {
LOG.error(e);
}
finally {
StreamUtil.closeStream(output);
}
}
示例10: copyProperties
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static void copyProperties(final String targetPath, final String fileName) throws IOException {
final File targetDir = new File(targetPath).getAbsoluteFile();
final File file = new File(targetDir, fileName);
FileUtil.createParentDirs(file);
for (File f = file; f != null && !FileUtil.filesEqual(f, targetDir); f = FileUtilRt.getParentFile(f)) {
f.deleteOnExit();
}
final String resourceName = "/" + fileName;
final InputStream stream = CopyResourcesUtil.class.getResourceAsStream(resourceName);
if (stream == null) {
return;
}
copyStreamToFile(stream, file);
}
示例11: BindingsCache
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public BindingsCache(final Project project) {
final File cacheStoreDirectory = CompilerPaths.getCacheStoreDirectory(project);
try {
if (cacheStoreDirectory != null) {
FileUtil.createParentDirs(cacheStoreDirectory);
myCache = createCache(cacheStoreDirectory);
}
else {
myCache = null;
}
}
catch (IOException e) {
LOG.info(e);
for (File file : cacheStoreDirectory.listFiles()) {
if (file.getName().startsWith(BINDINGS_FILE_NAME)) {
FileUtil.delete(file);
}
}
try {
myCache = createCache(cacheStoreDirectory);
}
catch (IOException e1) {
LOG.info(e1);
myCache = null;
}
}
}
示例12: createKeyStore
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static KeyStore createKeyStore(@NotNull String path, @NotNull String password) {
KeyStore keyStore;
try {
keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
File cacertsFile = new File(path);
if (cacertsFile.exists()) {
FileInputStream stream = null;
try {
stream = new FileInputStream(path);
keyStore.load(stream, password.toCharArray());
}
finally {
StreamUtil.closeStream(stream);
}
}
else {
if (!FileUtil.createParentDirs(cacertsFile)) {
LOG.error("Cannot create directories: " + cacertsFile.getParent());
return null;
}
keyStore.load(null, password.toCharArray());
}
}
catch (Exception e) {
LOG.error(e);
return null;
}
return keyStore;
}
示例13: getOrCreateVirtualFile
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
public static VirtualFile getOrCreateVirtualFile(@Nullable final Object requestor, @NotNull final File file) throws IOException {
VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
if (virtualFile != null) {
return virtualFile;
}
File absoluteFile = file.getAbsoluteFile();
FileUtil.createParentDirs(absoluteFile);
File parentFile = absoluteFile.getParentFile();
// need refresh if the directory has just been created
final VirtualFile parentVirtualFile = StringUtil.isEmpty(parentFile.getPath()) ? null : LocalFileSystem.getInstance().refreshAndFindFileByIoFile(parentFile);
if (parentVirtualFile == null) {
throw new IOException(ProjectBundle.message("project.configuration.save.file.not.found", parentFile));
}
if (ApplicationManager.getApplication().isWriteAccessAllowed()) {
return parentVirtualFile.createChildData(requestor, file.getName());
}
AccessToken token = WriteAction.start();
try {
return parentVirtualFile.createChildData(requestor, file.getName());
}
finally {
token.finish();
}
}
示例14: saveConversionResult
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static void saveConversionResult(ConversionContextImpl context) {
final CachedConversionResult conversionResult = new CachedConversionResult();
for (ConverterProvider provider : ConverterProvider.EP_NAME.getExtensions()) {
conversionResult.myAppliedConverters.add(provider.getId());
}
conversionResult.myProjectFilesTimestamps = getProjectFilesMap(context);
final File infoFile = getConversionInfoFile(context.getProjectFile());
FileUtil.createParentDirs(infoFile);
try {
JDOMUtil.writeDocument(new Document(XmlSerializer.serialize(conversionResult)), infoFile, SystemProperties.getLineSeparator());
}
catch (IOException e) {
LOG.info(e);
}
}
示例15: downloadContentToFile
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static void downloadContentToFile(@Nullable ProgressIndicator progress,
@NotNull String url,
@NotNull File outputFile) throws IOException {
boolean parentDirExists = FileUtil.createParentDirs(outputFile);
if (!parentDirExists) {
throw new IOException("Parent dir of '" + outputFile.getAbsolutePath() + "' can not be created!");
}
OutputStream out = new FileOutputStream(outputFile);
try {
download(progress, url, out);
}
finally {
out.close();
}
}