Codota Logo
IOUtils.closeStream
Code IndexAdd Codota to your IDE (free)

How to use
closeStream
method
in
org.apache.zookeeper.common.IOUtils

Best Java code snippets using org.apache.zookeeper.common.IOUtils.closeStream (Showing top 10 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: apache/zookeeper

/**
 * Copies from one stream to another.
 * 
 * @param in
 *            InputStrem to read from
 * @param out
 *            OutputStream to write to
 * @param buffSize
 *            the size of the buffer
 * @param close
 *            whether or not close the InputStream and OutputStream at the
 *            end. The streams are closed in the finally clause.
 */
public static void copyBytes(InputStream in, OutputStream out,
    int buffSize, boolean close) throws IOException {
  try {
    copyBytes(in, out, buffSize);
    if (close) {
      out.close();
      out = null;
      in.close();
      in = null;
    }
  } finally {
    if (close) {
      closeStream(out);
      closeStream(in);
    }
  }
}
origin: apache/zookeeper

IOUtils.closeStream(out);
origin: org.apache.zookeeper/zookeeper

/**
 * Copies from one stream to another.
 * 
 * @param in
 *            InputStrem to read from
 * @param out
 *            OutputStream to write to
 * @param buffSize
 *            the size of the buffer
 * @param close
 *            whether or not close the InputStream and OutputStream at the
 *            end. The streams are closed in the finally clause.
 */
public static void copyBytes(InputStream in, OutputStream out,
    int buffSize, boolean close) throws IOException {
  try {
    copyBytes(in, out, buffSize);
    if (close) {
      out.close();
      out = null;
      in.close();
      in = null;
    }
  } finally {
    if (close) {
      closeStream(out);
      closeStream(in);
    }
  }
}
origin: org.apache.zookeeper/zookeeper

IOUtils.closeStream(out);
origin: apache/zookeeper

  /**
   * Builds a SetTraceMask request to be sent to the server, consisting of
   * "stmk" followed by the 8-byte long representation of the trace mask.
   *
   * @param mask trace mask to set
   * @return built request
   * @throws IOException if there is an I/O error
   */
  private String buildSetTraceMaskRequest(long mask) throws IOException {
    ByteArrayOutputStream baos = null;
    DataOutputStream dos = null;
    try {
      baos = new ByteArrayOutputStream();
      dos = new DataOutputStream(baos);
      dos.writeBytes("stmk");
      dos.writeLong(mask);
    } finally {
      IOUtils.closeStream(dos);
      IOUtils.closeStream(baos);
    }
    return new String(baos.toByteArray());
  }
}
origin: apache/zookeeper

IOUtils.closeStream(out);
origin: ShifuML/guagua

  private static void writeJobSplitMetaInfo(FileSystem fs, Path filename, FsPermission p, int splitMetaInfoVersion,
      JobSplit.SplitMetaInfo[] allSplitMetaInfo) throws IOException {
    // write the splits meta-info to a file for the job tracker
    FSDataOutputStream out = null;
    try {
      out = FileSystem.create(fs, filename, p);
      out.write(META_SPLIT_FILE_HEADER);
      WritableUtils.writeVInt(out, splitMetaInfoVersion);
      WritableUtils.writeVInt(out, allSplitMetaInfo.length);
      for(JobSplit.SplitMetaInfo splitMetaInfo: allSplitMetaInfo) {
        splitMetaInfo.write(out);
      }
    } finally {
      IOUtils.closeStream(out);
    }
  }
}
origin: ml.shifu/guagua-yarn

  private static void writeJobSplitMetaInfo(FileSystem fs, Path filename, FsPermission p, int splitMetaInfoVersion,
      JobSplit.SplitMetaInfo[] allSplitMetaInfo) throws IOException {
    // write the splits meta-info to a file for the job tracker
    FSDataOutputStream out = null;
    try {
      out = FileSystem.create(fs, filename, p);
      out.write(META_SPLIT_FILE_HEADER);
      WritableUtils.writeVInt(out, splitMetaInfoVersion);
      WritableUtils.writeVInt(out, allSplitMetaInfo.length);
      for(JobSplit.SplitMetaInfo splitMetaInfo: allSplitMetaInfo) {
        splitMetaInfo.write(out);
      }
    } finally {
      IOUtils.closeStream(out);
    }
  }
}
origin: ml.shifu/guagua-yarn

@SuppressWarnings({ "unchecked", "unused" })
private <T> T getSplitDetails(Path file, long offset) throws IOException {
  FileSystem fs = file.getFileSystem(getYarnConf());
  FSDataInputStream inFile = null;
  T split = null;
  try {
    inFile = fs.open(file);
    inFile.seek(offset);
    String className = Text.readString(inFile);
    Class<T> cls;
    try {
      cls = (Class<T>) getYarnConf().getClassByName(className);
    } catch (ClassNotFoundException ce) {
      IOException wrap = new IOException(String.format("Split class %s not found", className));
      wrap.initCause(ce);
      throw wrap;
    }
    SerializationFactory factory = new SerializationFactory(getYarnConf());
    Deserializer<T> deserializer = (Deserializer<T>) factory.getDeserializer(cls);
    deserializer.open(inFile);
    split = deserializer.deserialize(null);
  } finally {
    IOUtils.closeStream(inFile);
  }
  return split;
}
origin: ShifuML/guagua

@SuppressWarnings({ "unchecked", "unused" })
private <T> T getSplitDetails(Path file, long offset) throws IOException {
  FileSystem fs = file.getFileSystem(getYarnConf());
  FSDataInputStream inFile = null;
  T split = null;
  try {
    inFile = fs.open(file);
    inFile.seek(offset);
    String className = Text.readString(inFile);
    Class<T> cls;
    try {
      cls = (Class<T>) getYarnConf().getClassByName(className);
    } catch (ClassNotFoundException ce) {
      IOException wrap = new IOException(String.format("Split class %s not found", className));
      wrap.initCause(ce);
      throw wrap;
    }
    SerializationFactory factory = new SerializationFactory(getYarnConf());
    Deserializer<T> deserializer = (Deserializer<T>) factory.getDeserializer(cls);
    deserializer.open(inFile);
    split = deserializer.deserialize(null);
  } finally {
    IOUtils.closeStream(inFile);
  }
  return split;
}
org.apache.zookeeper.commonIOUtilscloseStream

Javadoc

Closes the stream ignoring IOException. Must only be called in cleaning up from exception handlers.

Popular methods of IOUtils

  • copyBytes
    Copies from one stream to another.
  • cleanup
    Close the Closeable objects and ignore any IOException or null pointers. Must only be used for clean

Popular in Java

  • Updating database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • getExternalFilesDir (Context)
  • requestLocationUpdates (LocationManager)
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Reference (javax.naming)
  • JLabel (javax.swing)
  • JTextField (javax.swing)
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