org.openl.util.IOUtils.closeQuietly()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中org.openl.util.IOUtils.closeQuietly()方法的一些代码示例,展示了IOUtils.closeQuietly()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.closeQuietly()方法的具体详情如下:
包路径:org.openl.util.IOUtils
类名称:IOUtils
方法名:closeQuietly

IOUtils.closeQuietly介绍

[英]Unconditionally close a Closeable.

Equivalent to Closeable#close(), except any exceptions will be ignored.
[中]无条件关闭Closeable
与Closeable#close()等效,但任何异常都将被忽略。

代码示例

代码示例来源:origin: org.openl.rules/org.openl.rules.ruleservice.deployer

  1. @Override
  2. public void close() {
  3. if (deployRepo instanceof Closeable) {
  4. // Close repo connection after validation
  5. IOUtils.closeQuietly((Closeable) deployRepo);
  6. }
  7. }
  8. }

代码示例来源:origin: openl-tablets/openl-tablets

  1. @Override
  2. public void close() {
  3. if (deployRepo instanceof Closeable) {
  4. // Close repo connection after validation
  5. IOUtils.closeQuietly((Closeable) deployRepo);
  6. }
  7. }
  8. }

代码示例来源:origin: openl-tablets/openl-tablets

  1. @Override
  2. public void close() {
  3. IOUtils.closeQuietly(openedStream);
  4. openedStream = null;
  5. }

代码示例来源:origin: org.openl.rules/org.openl.rules.repository.jcr.jackrabbit

  1. private static boolean isFileLocked(File file) {
  2. FileInputStream fileInputStream = null;
  3. try {
  4. fileInputStream = new FileInputStream(file);
  5. fileInputStream.read();
  6. return false;
  7. } catch (IOException e) {
  8. return true;
  9. } finally {
  10. IOUtils.closeQuietly(fileInputStream);
  11. }
  12. }

代码示例来源:origin: org.openl.rules/org.openl.rules.webstudio

  1. public void releaseRepository(String propertiesFileName) throws RRepositoryException {
  2. synchronized (this) {
  3. Repository repository = factories.get(propertiesFileName);
  4. if (repository != null) {
  5. if (repository instanceof Closeable) {
  6. // Close repo connection after validation
  7. IOUtils.closeQuietly((Closeable) repository);
  8. }
  9. factories.remove(propertiesFileName);
  10. }
  11. }
  12. }

代码示例来源:origin: org.openl.rules/org.openl.rules.webstudio

  1. public void destroy() throws RRepositoryException {
  2. synchronized (this) {
  3. for (Repository repository : factories.values()) {
  4. if (repository instanceof Closeable) {
  5. // Close repo connection after validation
  6. IOUtils.closeQuietly((Closeable) repository);
  7. }
  8. }
  9. factories.clear();
  10. }
  11. }

代码示例来源:origin: openl-tablets/openl-tablets

  1. public void destroy() {
  2. synchronized (this) {
  3. for (Repository repository : factories.values()) {
  4. if (repository instanceof Closeable) {
  5. // Close repo connection after validation
  6. IOUtils.closeQuietly((Closeable) repository);
  7. }
  8. }
  9. factories.clear();
  10. }
  11. }

代码示例来源:origin: openl-tablets/openl-tablets

  1. public void releaseRepository(String propertiesFileName) {
  2. synchronized (this) {
  3. Repository repository = factories.get(propertiesFileName);
  4. if (repository != null) {
  5. if (repository instanceof Closeable) {
  6. // Close repo connection after validation
  7. IOUtils.closeQuietly((Closeable) repository);
  8. }
  9. factories.remove(propertiesFileName);
  10. }
  11. }
  12. }

代码示例来源:origin: openl-tablets/openl-tablets

  1. private static boolean isFileLocked(File file) {
  2. FileInputStream fileInputStream = null;
  3. try {
  4. fileInputStream = new FileInputStream(file);
  5. fileInputStream.read();
  6. return false;
  7. } catch (IOException e) {
  8. return true;
  9. } finally {
  10. IOUtils.closeQuietly(fileInputStream);
  11. }
  12. }

代码示例来源:origin: org.openl.rules/org.openl.rules.webstudio

  1. private boolean isEmptyZip(File uploadedFile) {
  2. ZipInputStream zipInputStream = null;
  3. try {
  4. zipInputStream = new ZipInputStream(new FileInputStream(uploadedFile), charset);
  5. if (zipInputStream.getNextEntry() == null) {
  6. return true;
  7. }
  8. } catch (IOException ignored) {
  9. } finally {
  10. IOUtils.closeQuietly(zipInputStream);
  11. }
  12. return false;
  13. }

代码示例来源:origin: openl-tablets/openl-tablets

  1. private Properties loadVelocityProperties() throws IOException, FileNotFoundException {
  2. Properties properties = new Properties();
  3. FileInputStream is = new FileInputStream(new File(VELOCITY_PROPERTIES));
  4. properties.load(is);
  5. IOUtils.closeQuietly(is);
  6. return properties;
  7. }

代码示例来源:origin: org.openl.rules/org.openl.rules.webstudio

  1. @Override
  2. public void destroy() {
  3. for (ProjectFile file : files) {
  4. IOUtils.closeQuietly(file.getInput());
  5. }
  6. }

代码示例来源:origin: openl-tablets/openl-tablets

  1. @Override
  2. public void destroy() {
  3. for (ProjectFile file : files) {
  4. IOUtils.closeQuietly(file.getInput());
  5. }
  6. }

代码示例来源:origin: org.openl.rules/org.openl.rules.webstudio

  1. public void setSupportedVersion(File projectFolder, SupportedVersion version) throws IOException {
  2. Properties properties = new Properties();
  3. properties.setProperty(OPENL_COMPATIBILITY_VERSION, version.getVersion());
  4. FileOutputStream os = null;
  5. try {
  6. File file = new File(projectFolder, OPENL_PROJECT_PROPERTIES_FILE);
  7. os = new FileOutputStream(file);
  8. properties.store(os, "Openl project properties");
  9. os.close();
  10. } finally {
  11. IOUtils.closeQuietly(os);
  12. }
  13. }

代码示例来源:origin: org.openl.rules/org.openl.rules.project

  1. public ProjectDescriptor readOriginalDescriptor(File filename) throws FileNotFoundException, ValidationException {
  2. FileInputStream inputStream = new FileInputStream(filename);
  3. ProjectDescriptor descriptor = readDescriptorInternal(inputStream);
  4. IOUtils.closeQuietly(inputStream);
  5. validator.validate(descriptor);
  6. return descriptor;
  7. }

代码示例来源:origin: openl-tablets/openl-tablets

  1. public ProjectDescriptor readOriginalDescriptor(File filename) throws FileNotFoundException, ValidationException {
  2. FileInputStream inputStream = new FileInputStream(filename);
  3. ProjectDescriptor descriptor = readDescriptorInternal(inputStream);
  4. IOUtils.closeQuietly(inputStream);
  5. validator.validate(descriptor);
  6. return descriptor;
  7. }

代码示例来源:origin: org.openl.rules/org.openl.rules.project

  1. public ProjectDescriptor readDescriptor(File file) throws IOException, ValidationException {
  2. FileInputStream inputStream = new FileInputStream(file);
  3. ProjectDescriptor descriptor = readDescriptorInternal(inputStream);
  4. IOUtils.closeQuietly(inputStream);
  5. postProcess(descriptor, file);
  6. validator.validate(descriptor);
  7. return descriptor;
  8. }

代码示例来源:origin: openl-tablets/openl-tablets

  1. public void setContent(InputStream inputStream) throws ProjectException {
  2. FileOutputStream fos = null;
  3. try {
  4. fos = new FileOutputStream(source);
  5. IOUtils.copy(inputStream, fos);
  6. notifyModified();
  7. } catch (IOException e) {
  8. throw new ProjectException("Failed to set content.", e);
  9. } finally {
  10. IOUtils.closeQuietly(fos);
  11. }
  12. }

代码示例来源:origin: openl-tablets/openl-tablets

  1. public ProjectDescriptor readDescriptor(File file) throws IOException, ValidationException {
  2. FileInputStream inputStream = new FileInputStream(file);
  3. ProjectDescriptor descriptor = readDescriptorInternal(inputStream);
  4. IOUtils.closeQuietly(inputStream);
  5. postProcess(descriptor, file);
  6. validator.validate(descriptor);
  7. return descriptor;
  8. }

代码示例来源:origin: openl-tablets/openl-tablets

  1. public void setContent(InputStream inputStream) throws ProjectException {
  2. try {
  3. getProject().lock();
  4. setFileData(getRepository().save(getFileData(), inputStream));
  5. } catch (IOException ex) {
  6. throw new ProjectException("Cannot set content", ex);
  7. } finally {
  8. IOUtils.closeQuietly(inputStream);
  9. }
  10. }

相关文章