当前位置: 首页>>代码示例>>Java>>正文


Java StreamUtil.closeStream方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.io.StreamUtil.closeStream方法的典型用法代码示例。如果您正苦于以下问题:Java StreamUtil.closeStream方法的具体用法?Java StreamUtil.closeStream怎么用?Java StreamUtil.closeStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.io.StreamUtil的用法示例。


在下文中一共展示了StreamUtil.closeStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyWithFiltering

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
private static void copyWithFiltering(File file, Ref<File> outputFileRef, List<ResourceRootFilter> filters, CompileContext context)
  throws IOException {
  final FileInputStream originalInputStream = new FileInputStream(file);
  try {
    final InputStream inputStream = transform(filters, originalInputStream, outputFileRef, context);
    FileUtil.createIfDoesntExist(outputFileRef.get());
    FileOutputStream outputStream = new FileOutputStream(outputFileRef.get());
    try {
      FileUtil.copy(inputStream, outputStream);
    }
    finally {
      StreamUtil.closeStream(inputStream);
      StreamUtil.closeStream(outputStream);
    }
  }
  finally {
    StreamUtil.closeStream(originalInputStream);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GradleResourceFileProcessor.java

示例2: save

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ExternalProjectSerializer.java

示例3: load

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
@Nullable
public ExternalProject load(@NotNull ProjectSystemId externalSystemId, File externalProjectPath) {
  LOG.debug("Attempt to load project data from: " + externalProjectPath);
  ExternalProject externalProject = null;
  Input input = null;
  try {
    final File configurationFile = getProjectConfigurationFile(externalSystemId, externalProjectPath);
    if (configurationFile.isFile()) {
      input = new Input(new FileInputStream(configurationFile));
      externalProject = myKryo.readObject(input, DefaultExternalProject.class);
    }
  }
  catch (Exception e) {
    LOG.error(e);
  }
  finally {
    StreamUtil.closeStream(input);
  }

  if (externalProject != null) {
    LOG.debug("Loaded project: " + externalProject.getProjectDir());
  }
  return externalProject;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ExternalProjectSerializer.java

示例4: readEntry

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
@Nullable
String readEntry(Condition<ZipEntry> condition) {
  ZipInputStream stream = null;
  try {
    stream = getStream();
    ZipEntry entry;
    while ((entry = stream.getNextEntry()) != null) {
      if (condition.value(entry)) {
        return StreamUtil.readText(stream, TemplateModuleBuilder.UTF_8);
      }
    }
  }
  catch (IOException e) {
    return null;
  }
  finally {
    StreamUtil.closeStream(stream);
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:LocalArchivedTemplate.java

示例5: getTemplates

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
private static MultiMap<String, ArchivedProjectTemplate> getTemplates() {
  InputStream stream = null;
  HttpURLConnection connection = null;
  String code = ApplicationInfo.getInstance().getBuild().getProductCode();
  try {
    connection = getConnection(code + "_templates.xml");
    stream = connection.getInputStream();
    String text = StreamUtil.readText(stream, TemplateModuleBuilder.UTF_8);
    return createFromText(text);
  }
  catch (IOException ex) {  // timeouts, lost connection etc
    LOG.info(ex);
    return MultiMap.emptyInstance();
  }
  catch (Exception e) {
    LOG.error(e);
    return MultiMap.emptyInstance();
  }
  finally {
    StreamUtil.closeStream(stream);
    if (connection != null) {
      connection.disconnect();
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:RemoteTemplatesFactory.java

示例6: loadKeyStore

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
private KeyStore loadKeyStore(String path, String password) {
  KeyStore keyStore = null;
  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 {
      FileUtil.createParentDirs(cacertsFile);
      keyStore.load(null, password.toCharArray());
    }
  }
  catch (Exception e) {
    LOG.error(e);
    broken = true;
  }
  return keyStore;
}
 
开发者ID:consulo,项目名称:consulo-tasks,代码行数:27,代码来源:CertificatesManager.java

示例7: addCertificate

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
public boolean addCertificate(X509Certificate certificate) {
  if (broken) {
    return false;
  }
  String alias = certificate.getIssuerX500Principal().getName();
  FileOutputStream stream = null;
  try {
    myKeyStore.setCertificateEntry(alias, certificate);
    stream = new FileOutputStream(myPath);
    myKeyStore.store(stream, myPassword.toCharArray());
    // trust manager should be updated each time its key store was modified
    myTrustManager = initFactoryAndGetManager();
    return true;
  }
  catch (Exception e) {
    LOG.error(e);
    return false;
  }
  finally {
    StreamUtil.closeStream(stream);
  }
}
 
开发者ID:consulo,项目名称:consulo-tasks,代码行数:23,代码来源:CertificatesManager.java

示例8: computeNamespace

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
@Nullable
public static String computeNamespace(@NotNull VirtualFile file)
{
	InputStream stream = null;
	try
	{
		stream = file.getInputStream();
		return XsdNamespaceBuilder.computeNamespace(stream);
	}
	catch(IOException e)
	{
		return null;
	}
	finally
	{
		StreamUtil.closeStream(stream);
	}
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:19,代码来源:XmlNamespaceIndex.java

示例9: consumeZipStream

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
static <T> T consumeZipStream(@NotNull StreamProcessor<T> consumer, @NotNull ZipInputStream stream) throws IOException {
  try {
    return consumer.consume(stream);
  }
  finally {
    StreamUtil.closeStream(stream);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ArchivedProjectTemplate.java

示例10: createKeyStore

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:ConfirmingTrustManager.java

示例11: flushKeyStore

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
private void flushKeyStore() throws Exception {
  FileOutputStream stream = new FileOutputStream(myPath);
  try {
    myKeyStore.store(stream, myPassword.toCharArray());
  }
  finally {
    StreamUtil.closeStream(stream);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ConfirmingTrustManager.java

示例12: getBrokenPluginVersions

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
@NotNull
private static MultiMap<String, String> getBrokenPluginVersions() {
  if (ourBrokenPluginVersions == null) {
    ourBrokenPluginVersions = MultiMap.createSet();

    if (System.getProperty("idea.ignore.disabled.plugins") == null && !isUnitTestMode()) {
      BufferedReader br = new BufferedReader(new InputStreamReader(PluginManagerCore.class.getResourceAsStream("/brokenPlugins.txt")));
      try {
        String s;
        while ((s = br.readLine()) != null) {
          s = s.trim();
          if (s.startsWith("//")) continue;

          List<String> tokens = ParametersListUtil.parse(s);
          if (tokens.isEmpty()) continue;

          if (tokens.size() == 1) {
            throw new RuntimeException("brokenPlugins.txt is broken. The line contains plugin name, but does not contains version: " + s);
          }

          String pluginId = tokens.get(0);
          List<String> versions = tokens.subList(1, tokens.size());

          ourBrokenPluginVersions.putValues(pluginId, versions);
        }
      }
      catch (IOException e) {
        throw new RuntimeException("Failed to read /brokenPlugins.txt", e);
      }
      finally {
        StreamUtil.closeStream(br);
      }
    }
  }
  return ourBrokenPluginVersions;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:PluginManagerCore.java

示例13: computeNamespace

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
@Nullable
public static String computeNamespace(@NotNull VirtualFile file) {
  InputStream stream = null;
  try {
    stream = file.getInputStream();
    return XsdNamespaceBuilder.computeNamespace(stream);
  }
  catch (IOException e) {
    return null;
  }
  finally {
    StreamUtil.closeStream(stream);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:XmlNamespaceIndex.java

示例14: generateInitScript

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
@Nullable
public static File generateInitScript(boolean isBuildSrcProject, @NotNull Set<Class> toolingExtensionClasses) {
  InputStream stream = Init.class.getResourceAsStream("/org/jetbrains/plugins/gradle/tooling/internal/init/init.gradle");
  try {
    if (stream == null) {
      LOG.warn("Can't get init script template");
      return null;
    }
    final String toolingExtensionsJarPaths = getToolingExtensionsJarPaths(toolingExtensionClasses);
    String s = FileUtil.loadTextAndClose(stream).replaceFirst(Pattern.quote("${EXTENSIONS_JARS_PATH}"), toolingExtensionsJarPaths);
    if (isBuildSrcProject) {
      String buildSrcDefaultInitScript = getBuildSrcDefaultInitScript();
      if (buildSrcDefaultInitScript == null) return null;
      s += buildSrcDefaultInitScript;
    }

    final File tempFile = FileUtil.createTempFile("ijinit", '.' + GradleConstants.EXTENSION, true);
    FileUtil.writeToFile(tempFile, s);
    return tempFile;
  }
  catch (Exception e) {
    LOG.warn("Can't generate IJ gradle init script", e);
    return null;
  }
  finally {
    StreamUtil.closeStream(stream);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:GradleExecutionHelper.java

示例15: getBuildSrcDefaultInitScript

import com.intellij.openapi.util.io.StreamUtil; //导入方法依赖的package包/类
@Nullable
public static String getBuildSrcDefaultInitScript() {
  InputStream stream = Init.class.getResourceAsStream("/org/jetbrains/plugins/gradle/tooling/internal/init/buildSrcInit.gradle");
  try {
    if (stream == null) return null;
    return FileUtil.loadTextAndClose(stream);
  }
  catch (Exception e) {
    LOG.warn("Can't use IJ gradle init script", e);
    return null;
  }
  finally {
    StreamUtil.closeStream(stream);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:GradleExecutionHelper.java


注:本文中的com.intellij.openapi.util.io.StreamUtil.closeStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。