Package com.intellij.openapi.util.io

Examples of com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream


    final byte[] outputBytes;
    final int outputBytesLength;
    if (entry.getMethod() == ZipEntry.DEFLATED) {
      def.setLevel(level);
      final BufferExposingByteArrayOutputStream compressedBytesStream = new BufferExposingByteArrayOutputStream();
      final DeflaterOutputStream stream = new DeflaterOutputStream(compressedBytesStream, def);
      try {
        stream.write(bytes);
      }
      finally {
        stream.close();
      }
      outputBytesLength = compressedBytesStream.size();
      outputBytes = compressedBytesStream.getInternalBuffer();
    }
    else {
      outputBytesLength = bytes.length;
      outputBytes = bytes;
    }
View Full Code Here


      markDirty(true);

      final int dataOff = myKeyStorage != null ? (int)myKeyStorage.length() : ((InlineKeyDescriptor<Data>)myDataDescriptor).toInt(value);

      if (myKeyStorage != null) {
        final BufferExposingByteArrayOutputStream bos = new BufferExposingByteArrayOutputStream();
        DataOutput out = new DataOutputStream(bos);
        myDataDescriptor.save(out, value);
        myKeyStorage.put(dataOff, bos.getInternalBuffer(), 0, bos.size());
      }

      return setupValueId(hashCode, dataOff);
    }
    catch (IOException e) {
View Full Code Here

  }

  public static Image loadFromStream(@NotNull final InputStream inputStream) {
    try {

      BufferExposingByteArrayOutputStream outputStream = new BufferExposingByteArrayOutputStream();
      try {
        byte[] buffer = new byte[1024];
        while (true) {
          final int n = inputStream.read(buffer);
          if (n < 0) break;
          outputStream.write(buffer, 0, n);
        }
      }
      finally {
        inputStream.close();
      }

      Image image = Toolkit.getDefaultToolkit().createImage(outputStream.getInternalBuffer(), 0, outputStream.size());
      waitForImage(image);

      return image;
    } catch (Exception ex) {
      LOG.error(ex);
View Full Code Here

  private boolean myIntAddressForNewRecord;
  private static final boolean doHardConsistencyChecks = false;

  private static class AppendStream extends DataOutputStream {
    private AppendStream() {
      super(new BufferExposingByteArrayOutputStream());
    }
View Full Code Here

    public byte[] toByteArray() {
      return ((ByteArrayOutputStream)out).toByteArray();
    }
   
    public ByteSequence getInternalBuffer() {
      final BufferExposingByteArrayOutputStream _out = (BufferExposingByteArrayOutputStream)out;
      return new ByteSequence(_out.getInternalBuffer(), 0, _out.size());
    }
View Full Code Here

    synchronized (myLock) {
      Future<Object> future = myPendingWriteRequestsExecutor.submit(new Callable<Object>() {
        @Override
        public Object call() throws IOException {
          BufferExposingByteArrayOutputStream s = new BufferExposingByteArrayOutputStream();
          DeflaterOutputStream out = new DeflaterOutputStream(s);
          try {
            out.write(bytes.getBytes(), bytes.getOffset(), bytes.getLength());
          }
          finally {
View Full Code Here

    private final AbstractStorage myStorage;
    private final int myRecordId;
    private final boolean myFixedSize;

    private StorageDataOutput(AbstractStorage storage, int recordId, boolean fixedSize) {
      super(new BufferExposingByteArrayOutputStream());
      myStorage = storage;
      myRecordId = recordId;
      myFixedSize = fixedSize;
    }
View Full Code Here

      myFixedSize = fixedSize;
    }

    public void close() throws IOException {
      super.close();
      final BufferExposingByteArrayOutputStream byteStream = getByteStream();
      myStorage.writeBytes(myRecordId, new ByteSequence(byteStream.getInternalBuffer(), 0, byteStream.size()), myFixedSize);
    }
View Full Code Here

  public class AppenderStream extends DataOutputStream {
    private final int myRecordId;

    private AppenderStream(int recordId) {
      super(new BufferExposingByteArrayOutputStream());
      myRecordId = recordId;
    }
View Full Code Here

      myRecordId = recordId;
    }

    public void close() throws IOException {
      super.close();
      final BufferExposingByteArrayOutputStream _out = (BufferExposingByteArrayOutputStream)out;
      appendBytes(myRecordId, new ByteSequence(_out.getInternalBuffer(), 0, _out.size()));
    }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.