Java 类com.intellij.util.io.ReplicatorInputStream 实例源码

项目:intellij-ce-playground    文件:PersistentFSImpl.java   
private InputStream createReplicator(@NotNull final VirtualFile file,
                                     final InputStream nativeStream,
                                     final long fileLength,
                                     final boolean readOnly) throws IOException {
  if (nativeStream instanceof BufferExposingByteArrayInputStream) {
    // optimization
    BufferExposingByteArrayInputStream  byteStream = (BufferExposingByteArrayInputStream )nativeStream;
    byte[] bytes = byteStream.getInternalBuffer();
    storeContentToStorage(fileLength, file, readOnly, bytes, bytes.length);
    return nativeStream;
  }
  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
  final BufferExposingByteArrayOutputStream cache = new BufferExposingByteArrayOutputStream((int)fileLength);
  return new ReplicatorInputStream(nativeStream, cache) {
    @Override
    public void close() throws IOException {
      super.close();
      storeContentToStorage(fileLength, file, readOnly, cache.getInternalBuffer(), cache.size());
    }
  };
}
项目:tools-idea    文件:PersistentFSImpl.java   
private InputStream createReplicator(@NotNull final VirtualFile file, final InputStream nativeStream, final long fileLength, final boolean readOnly)
  throws IOException {
  if (nativeStream instanceof BufferExposingByteArrayInputStream) {
    // optimization
    BufferExposingByteArrayInputStream  byteStream = (BufferExposingByteArrayInputStream )nativeStream;
    byte[] bytes = byteStream.getInternalBuffer();
    storeContentToStorage(fileLength, file, readOnly, bytes, bytes.length);
    return nativeStream;
  }
  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
  final BufferExposingByteArrayOutputStream cache = new BufferExposingByteArrayOutputStream((int)fileLength);
  return new ReplicatorInputStream(nativeStream, cache) {
    @Override
    public void close() throws IOException {
      super.close();
      storeContentToStorage(fileLength, file, readOnly, cache.getInternalBuffer(), cache.size());
    }
  };
}
项目:consulo    文件:PersistentFSImpl.java   
private InputStream createReplicator(@Nonnull final VirtualFile file, final InputStream nativeStream, final long fileLength, final boolean readOnly)
        throws IOException {
  if (nativeStream instanceof BufferExposingByteArrayInputStream) {
    // optimization
    BufferExposingByteArrayInputStream byteStream = (BufferExposingByteArrayInputStream)nativeStream;
    byte[] bytes = byteStream.getInternalBuffer();
    storeContentToStorage(fileLength, file, readOnly, bytes, bytes.length);
    return nativeStream;
  }
  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
  final BufferExposingByteArrayOutputStream cache = new BufferExposingByteArrayOutputStream((int)fileLength);
  return new ReplicatorInputStream(nativeStream, cache) {
    @Override
    public void close() throws IOException {
      super.close();
      storeContentToStorage(fileLength, file, readOnly, cache.getInternalBuffer(), cache.size());
    }
  };
}