Tabnine Logo
CloseUtils.safeClose
Code IndexAdd Tabnine to your IDE (free)

How to use
safeClose
method
in
org.dcm4che2.util.CloseUtils

Best Java code snippets using org.dcm4che2.util.CloseUtils.safeClose (Showing top 11 results out of 315)

origin: dcm4che/dcm4che-core

  public static void serializeTo(Object o, File out) throws IOException {
    FileOutputStream fos = new FileOutputStream(out);
    ObjectOutputStream oos = null;
    try {
      oos = new ObjectOutputStream(fos);
      oos.writeObject(o);
    } finally {
      CloseUtils.safeClose(oos);
      CloseUtils.safeClose(fos);
    }
  }
}
origin: dcm4che/dcm4che-core

private void writeToFile(byte[] data) throws IOException {
  if (file == null)
    return;
  file.getParentFile().mkdirs();
  FileOutputStream out = new FileOutputStream(file);
  try {
    out.write(data);
  } finally {
    CloseUtils.safeClose(out);
  }
}
origin: dcm4che/dcm4che-core

public DicomInputStream(File f) throws IOException {
  super(new BufferedInputStream(new FileInputStream(f)));
  try {
    this.ts = guessTransferSyntax();
  } catch (IOException e) {
    CloseUtils.safeClose(this);
    throw e;
  }
}
origin: dcm4che/dcm4che-net

private void closeSocket() {
  if (state == State.STA13) {
    try {
      Thread.sleep(connector.getSocketCloseDelay());
    } catch (InterruptedException e) {
      log.warn("Interrupted Socket Close Delay", e);
    }
  }
  setState(State.STA1);
  CloseUtils.safeClose(out);
  CloseUtils.safeClose(in);
  if (!closed) {
    log.info("{}: close {}", name, socket);
    CloseUtils.safeClose(socket);
    closed = true;
    onClosed();
  }
}
origin: dcm4che/dcm4che-imageio

protected ImageReaderWriterFactory(String key, String def) {
  String val = System.getProperty(key, def);
  URL url;
  try {
    url = new URL(val);
  } catch (MalformedURLException e) {
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if (cl == null || (url = cl.getResource(val)) == null) {
      if ((url = ImageReaderWriterFactory.class.getClassLoader()
          .getResource(val)) == null) {
        throw new ConfigurationError("missing resource: " + val);
      }
    }
  }
  
  InputStream is = null;
  try {
    is = url.openStream();
    config.load(is);
  } catch (IOException e) {
    throw new ConfigurationError(
        "failed to load imageio configuration from " + url, e);
  } finally {
    CloseUtils.safeClose(is);
  }
}
origin: dcm4che/dcm4che-core

public static Object loadResource(String name) {
  ClassLoader cl = Thread.currentThread().getContextClassLoader();
  InputStream is;
  if (cl == null || (is = cl.getResourceAsStream(name)) == null) {
    is = ResourceLocator.class.getClassLoader().getResourceAsStream(
        name);
    if (is == null) {
      throw new ConfigurationError("Missing Resource: " + name);
    }
  }
  try {
    ObjectInputStream ois = new ObjectInputStream(is);
    return ois.readObject();
  } catch (Exception e) {
    throw new ConfigurationError("Failed to load Resource " + name, e);
  } finally {
    CloseUtils.safeClose(is);
  }
}
origin: dcm4che/dcm4che-core

      + url, e);
} finally {
  CloseUtils.safeClose(in);
origin: dcm4che/dcm4che-core

public static List<String> findResources(Class<?> c) {
  ArrayList<String> list = new ArrayList<String>();
  try {
    for (Enumeration<URL> configs = enumResources(PREFIX + c.getName());
        configs.hasMoreElements();) {
      URL u = configs.nextElement();
      InputStream in = u.openStream();
      try {
        BufferedReader r = new BufferedReader(
            new InputStreamReader(in, "utf-8"));
        String ln;
        while ((ln = r.readLine()) != null) {
          int end = ln.indexOf('#');
          if (end >= 0)
            ln = ln.substring(0, end);
          ln = ln.trim();
          if (ln.length() > 0)
            list.add(ln);
        }
      } finally {
        CloseUtils.safeClose(in);
      }
    }
    return list;
  } catch (IOException e) {
    throw new ConfigurationError("Failed to find Resources for " + c, e);
  }
}
origin: bioinformatics-ua/dicoogle

  return;
} finally {
  CloseUtils.safeClose(in);
origin: bioinformatics-ua/dicoogle

  return;
} finally {
  CloseUtils.safeClose(in);
origin: dcm4che/dcm4che-net

private DicomObject readDicomObject(TransferSyntax ts)
throws IOException
{
  DicomObject dcm = new BasicDicomObject();
  DicomInputStream din = new DicomInputStream(this, ts);
  try
  {
    din.readDicomObject(dcm, -1);
  }
  catch (DicomCodingException e)
  {
    log.warn(as.toString() + ": Failed to decode dicom object: " + e.getMessage());
    throw new AAbort();
  }
  finally {
    CloseUtils.safeClose(din);
  }
  return dcm;
}
org.dcm4che2.utilCloseUtilssafeClose

Javadoc

Safely close, absorbing exceptions and handling null graciously.

Popular methods of CloseUtils

  • log

Popular in Java

  • Start an intent from android
  • setScale (BigDecimal)
  • setContentView (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Permission (java.security)
    Legacy security code; do not use.
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • JCheckBox (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now