Tabnine Logo
com.mucommander.commons.io
Code IndexAdd Tabnine to your IDE (free)

How to use com.mucommander.commons.io

Best Java code snippets using com.mucommander.commons.io (Showing top 20 results out of 315)

origin: mucommander/mucommander

/**
 * This method is a shorthand for {@link #fillWithConstant(java.io.OutputStream, byte, long, int)} called with a
 * {@link BufferPool#getDefaultBufferSize default buffer size}.
 *
 * @param out the OutputStream to write to
 * @param value the byte constant to write len times
 * @param len number of bytes to write
 * @throws java.io.IOException if an error occurred while writing
 */
public static void fillWithConstant(OutputStream out, byte value, long len) throws IOException {
  fillWithConstant(out, value, len, BufferPool.getDefaultBufferSize());
}
origin: mucommander/mucommander

  /**
   * Returns this stream's digest, expressed as an hexadecimal string.
   *
   * @return this stream's digest, expressed as an hexadecimal string
   */
  public String getChecksumString() {
    return ByteUtils.toHexString(getChecksumBytes());
  }
}
origin: mucommander/mucommander

/**
 * This method is a shorthand for {@link #copyStream(java.io.InputStream, java.io.OutputStream, int)} called with a
 * {@link BufferPool#getDefaultBufferSize() default buffer size}.
 *
 * @param in the InputStream to read from
 * @param out the OutputStream to write to
 * @return the number of bytes that were copied
 * @throws FileTransferException if something went wrong while reading from or writing to one of the provided streams
 */
public static long copyStream(InputStream in, OutputStream out) throws FileTransferException {
  return copyStream(in, out, BufferPool.getDefaultBufferSize());
}
origin: mucommander/mucommander

/**
 * This method is a shorthand for {@link #readUntilEOF(java.io.InputStream, int)} called with a
 * {@link BufferPool#getDefaultBufferSize default buffer size}.
 *
 * @param in the InputStream to read
 * @throws IOException if an I/O error occurs
 */
public static void readUntilEOF(InputStream in) throws IOException {
  readUntilEOF(in, BufferPool.getDefaultBufferSize());
}
origin: mucommander/mucommander

/**
 * Convenience method that has the same effect as calling {@link #getByteArray(int)} with
 * a length equal to {@link #getDefaultBufferSize()}.
 *
 * @return a byte array with a length of {@link #getDefaultBufferSize()}
 */
public static synchronized byte[] getByteArray() {
  return getByteArray(getDefaultBufferSize());
}
origin: mucommander/mucommander

@Override
public synchronized void setLength(long newLength) throws IOException {
  // Flush before changing the file's length, otherwise the behavior of setLength() would be modified, especially
  // when truncating the file
  flush();
  raos.setLength(newLength);
}
origin: mucommander/mucommander

/**
 * This method is a shorthand for {@link #copyChunk(RandomAccessInputStream, RandomAccessOutputStream, long, long, long, int)}
 * called with a {@link BufferPool#getDefaultBufferSize default buffer size}.
 *
 * @param rais the source stream
 * @param raos the destination stream
 * @param srcOffset offset to the beginning of the chunk in the source stream
 * @param destOffset offset to the beginning of the chunk in the destination stream
 * @param length number of bytes to copy
 * @throws java.io.IOException if an error occurred while copying data
 */
public static void copyChunk(RandomAccessInputStream rais, RandomAccessOutputStream raos, long srcOffset, long destOffset, long length) throws IOException {
  copyChunk(rais, raos, srcOffset, destOffset, length, BufferPool.getDefaultBufferSize());
}
origin: mucommander/mucommander

public synchronized void seek(long offset) throws IOException {
  // Flush any buffered bytes before seeking, otherwise buffered bytes would be written at the wrong offset
  flush();
  raos.seek(offset);
}
origin: mucommander/mucommander

  @Override
  public void close() throws IOException {
    try {
      flush();
    }
    catch(IOException e) {
      // Try closing the stream anyway
    }

    raos.close();
  }
}
origin: mucommander/mucommander

/**
 * Returns the length of the given buffer, as defined by {@link com.mucommander.commons.io.BufferPool.BufferContainer#getLength()}.
 *
 * @param buffer the buffer for which to return the length
 * @param factory the factory that was used to create the buffer
 * @return the length of the given buffer
 */
private int getBufferLength(Object buffer, BufferPool.BufferFactory factory) {
  return factory.newBufferContainer(buffer).getLength();
}
origin: mucommander/mucommander

/**
 * Returns the size in bytes of the given buffer, as defined by {@link com.mucommander.commons.io.BufferPool.BufferContainer#getSize()}.
 *
 * @param buffer the buffer for which to return the size
 * @param factory the factory that was used to create the buffer
 * @return the size in bytes of the given buffer
 */
private int getBufferSize(Object buffer, BufferPool.BufferFactory factory) {
  return factory.newBufferContainer(buffer).getSize();
}
origin: mucommander/mucommander

/**
 * Creates a new <code>BufferedRandomOutputStream</code> on top of the given {@link RandomAccessOutputStream}.
 * An internal buffer of the specified size is created.
 *
 * @param raos the underlying RandomAccessOutputStream used by this buffered output stream
 * @param size size of the buffer in bytes
 */
public BufferedRandomOutputStream(RandomAccessOutputStream raos, int size) {
  this.raos = raos;
  this.buffer = BufferPool.getByteArray(size);
}
origin: mucommander/mucommander

/**
 * Returns the number of bytes that have been skipped in the current file. Bytes are skipped when file transfers
 * are resumed.
 *
 * @return the number of bytes that have been skipped in the current file
 */
public long getCurrentFileSkippedByteCount() {
  return currentFileSkippedByteCounter.getByteCount();
}
origin: mucommander/mucommander

/**
 * Flushes this buffered output stream. This forces any buffered
 * output bytes to be written out to the underlying output stream.
 *
 * @throws IOException if an I/O error occurs.
 */
@Override
public synchronized void flush() throws IOException {
  flushBuffer();
  raos.flush();
}
origin: mucommander/mucommander

  /**
   * Returns this stream's digest, expressed as an hexadecimal string.
   *
   * @return this stream's digest, expressed as an hexadecimal string
   */
  public String getChecksumString() {
    return ByteUtils.toHexString(getChecksumBytes());
  }
}
origin: mucommander/mucommander

/**
 * Checks if the current buffered block has been read completely (i.e. no more data is available) and if it has,
 * calls {@link #readBlock(long, byte[], int)} to fetch the next block.
 *
 * @throws IOException if an I/O error occurred
 */
private void checkBuffer() throws IOException {
  if(blockOff >= blockLen)      // True initially
    readBlock();
}
origin: mucommander/mucommander

/**
 * Increases the number of bytes read this second to the given number.
 *
 * @param nbRead number of bytes that have been read or skipped from the underlying stream.
 */
private void addToLimitCounter(long nbRead) {
  updateLimitCounter();
  this.nbBytesReadThisSecond += nbRead;
}
origin: mucommander/mucommander

  @Override
  public void close() throws IOException {
    super.close();
    // Declare the zip file and entries tree up-to-date and add the new entry to the entries tree
      finishAddEntry(entry);
    }
};
origin: mucommander/mucommander

/**
 * Returns the total number of bytes that have been processed by this job so far.
 *
 * @return the total number of bytes that have been processed by this job so far
 */
public long getTotalByteCount() {
  return totalByteCounter.getByteCount();
}
origin: mucommander/mucommander

public void seek(long newOffset) throws IOException {
  // If the new offset is within the current buffer's range, simply reposition the offsets
  if(newOffset>=offset && newOffset<offset+ blockLen) {
    blockOff += (int)(newOffset-offset);
    offset = newOffset;
  }
  // If not, retrieve a block of data starting at the new offset and fill the buffer with it
  else {
    offset = newOffset;
    readBlock();
  }
}
com.mucommander.commons.io

Most used classes

  • StreamUtils
    This class provides convenience static methods that operate on streams. All read/write buffers are a
  • BoundedInputStream
    BoundedInputStream is an InputStream that has a set limit to the number of bytes that can be read or
  • BufferPool
    This class allows to share and reuse byte buffers to avoid excessive memory allocation and garbage c
  • ChecksumInputStream
    This class extends java.security.DigestInputStream and adds convenience methods that return the dige
  • RandomAccessInputStream
    RandomAccessInputStream is an InputStream with random access. The following java.io.InputStream met
  • Base64Encoder,
  • EncodingDetector,
  • FileTransferException,
  • Base64Decoder,
  • BOMInputStream,
  • BOMWriter,
  • BinaryDetector,
  • BoundedOutputStream,
  • BoundedReader,
  • BufferPool$BufferContainer,
  • BufferPool$BufferFactory,
  • BufferPool$ByteArrayFactory,
  • BufferPool$ByteBufferFactory,
  • BufferPool$CharArrayFactory
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