Codota Logo
CloseUtils.safeClose
Code IndexAdd Codota 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)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
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
  • addToBackStack (FragmentTransaction)
  • requestLocationUpdates (LocationManager)
  • onCreateOptionsMenu (Activity)
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • Hashtable (java.util)
    Hashtable is a synchronized implementation of Map. All optional operations are supported.Neither key
  • Properties (java.util)
    The Properties class represents a persistent set of properties. The Properties can be saved to a st
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • JTextField (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now