当前位置: 首页>>代码示例>>Java>>正文


Java CountingOutputStream.getCount方法代码示例

本文整理汇总了Java中org.apache.commons.io.output.CountingOutputStream.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java CountingOutputStream.getCount方法的具体用法?Java CountingOutputStream.getCount怎么用?Java CountingOutputStream.getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.io.output.CountingOutputStream的用法示例。


在下文中一共展示了CountingOutputStream.getCount方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encodeAndWriteStream

import org.apache.commons.io.output.CountingOutputStream; //导入方法依赖的package包/类
/**
 * Encodes and writes a stream directly to an OutputStream. The length of
 * the stream, in this case, is set on a PDFNumber object that has to be
 * prepared beforehand.
 * @param out OutputStream to write to
 * @param refLength PDFNumber object to receive the stream length
 * @return number of bytes written (header and trailer included)
 * @throws IOException in case of an I/O problem
 */
protected int encodeAndWriteStream(OutputStream out, PDFNumber refLength)
            throws IOException {
    int bytesWritten = 0;
    //Stream header
    byte[] buf = encode("stream\n");
    out.write(buf);
    bytesWritten += buf.length;

    //Stream contents
    CloseBlockerOutputStream cbout = new CloseBlockerOutputStream(out);
    CountingOutputStream cout = new CountingOutputStream(cbout);
    OutputStream filteredOutput = getFilterList().applyFilters(cout);
    outputRawStreamData(filteredOutput);
    filteredOutput.close();
    refLength.setNumber(Integer.valueOf(cout.getCount()));
    bytesWritten += cout.getCount();

    //Stream trailer
    buf = encode("\nendstream");
    out.write(buf);
    bytesWritten += buf.length;

    return bytesWritten;
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:34,代码来源:AbstractPDFStream.java

示例2: output

import org.apache.commons.io.output.CountingOutputStream; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public int output(OutputStream stream) throws IOException {
    CountingOutputStream cout = new CountingOutputStream(stream);
    StringBuilder textBuffer = new StringBuilder(64);
    textBuffer.append('[');
    boolean first = true;
    for (Map.Entry<Integer, Object> entry : this.map.entrySet()) {
        if (!first) {
            textBuffer.append(" ");
        }
        first = false;
        formatObject(entry.getKey(), cout, textBuffer);
        textBuffer.append(" ");
        formatObject(entry.getValue(), cout, textBuffer);
    }
    textBuffer.append(']');
    PDFDocument.flushTextBuffer(textBuffer, cout);
    return cout.getCount();
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:21,代码来源:PDFNumsArray.java

示例3: output

import org.apache.commons.io.output.CountingOutputStream; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public int output(OutputStream stream) throws IOException {
    CountingOutputStream cout = new CountingOutputStream(stream);
    StringBuilder textBuffer = new StringBuilder(64);
    textBuffer.append('[');
    for (int i = 0; i < values.size(); i++) {
        if (i > 0) {
            textBuffer.append(' ');
        }
        Object obj = this.values.get(i);
        formatObject(obj, cout, textBuffer);
    }
    textBuffer.append(']');
    PDFDocument.flushTextBuffer(textBuffer, cout);
    return cout.getCount();
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:18,代码来源:PDFArray.java

示例4: getWriter

import org.apache.commons.io.output.CountingOutputStream; //导入方法依赖的package包/类
@Override
public FileWriter getWriter(final long bucketKey, final String fileName) throws IOException
{
  final DataOutputStream dos = getOutputStream(bucketKey, fileName);
  final CountingOutputStream cos = new CountingOutputStream(dos);
  final Output out = new Output(cos);

  return new FileWriter()
  {
    @Override
    public void close() throws IOException
    {
      out.close();
      cos.close();
      dos.close();
    }

    @Override
    public void append(byte[] key, byte[] value) throws IOException
    {
      kryo.writeObject(out, key);
      kryo.writeObject(out, value);
    }

    @Override
    public long getBytesWritten()
    {
      return cos.getCount() + out.position();
    }

  };

}
 
开发者ID:DataTorrent,项目名称:Megh,代码行数:34,代码来源:MockFileAccess.java

示例5: output

import org.apache.commons.io.output.CountingOutputStream; //导入方法依赖的package包/类
/**
 * Overload the base object method so we don't have to copy
 * byte arrays around so much
 * {@inheritDoc}
 */
@Override
public int output(OutputStream stream) throws IOException {
    setupFilterList();

    CountingOutputStream cout = new CountingOutputStream(stream);
    StringBuilder textBuffer = new StringBuilder(64);

    StreamCache encodedStream = null;
    PDFNumber refLength = null;
    final Object lengthEntry;
    if (encodeOnTheFly) {
        refLength = new PDFNumber();
        getDocumentSafely().registerObject(refLength);
        lengthEntry = refLength;
    } else {
        encodedStream = encodeStream();
        lengthEntry = Integer.valueOf(encodedStream.getSize() + 1);
    }

    populateStreamDict(lengthEntry);
    dictionary.writeDictionary(cout, textBuffer);

    //Send encoded stream to target OutputStream
    PDFDocument.flushTextBuffer(textBuffer, cout);
    if (encodedStream == null) {
        encodeAndWriteStream(cout, refLength);
    } else {
        outputStreamData(encodedStream, cout);
        encodedStream.clear(); //Encoded stream can now be discarded
    }

    PDFDocument.flushTextBuffer(textBuffer, cout);
    return cout.getCount();
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:40,代码来源:AbstractPDFStream.java

示例6: output

import org.apache.commons.io.output.CountingOutputStream; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public int output(OutputStream stream) throws IOException {
    CountingOutputStream cout = new CountingOutputStream(stream);
    StringBuilder textBuffer = new StringBuilder(64);
    writeDictionary(cout, textBuffer);
    PDFDocument.flushTextBuffer(textBuffer, cout);
    return cout.getCount();
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:10,代码来源:PDFDictionary.java

示例7: output

import org.apache.commons.io.output.CountingOutputStream; //导入方法依赖的package包/类
@Override
public int output(OutputStream stream) throws IOException {
    CountingOutputStream cout = new CountingOutputStream(stream);
    StringBuilder textBuffer = new StringBuilder(64);
    textBuffer.append(toString());
    PDFDocument.flushTextBuffer(textBuffer, cout);
    return cout.getCount();
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:9,代码来源:PDFName.java

示例8: output

import org.apache.commons.io.output.CountingOutputStream; //导入方法依赖的package包/类
@Override
public int output(OutputStream stream) throws IOException {
    CountingOutputStream cout = new CountingOutputStream(stream);
    StringBuilder textBuffer = new StringBuilder(64);

    formatObject(getIDRef(), cout, textBuffer);
    textBuffer.append(' ');
    formatObject(goToReference, cout, textBuffer);

    PDFDocument.flushTextBuffer(textBuffer, cout);
    return cout.getCount();
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:13,代码来源:PDFDestination.java

示例9: writeLogTo

import org.apache.commons.io.output.CountingOutputStream; //导入方法依赖的package包/类
/**
     * Writes the section of the file {@link OutputStream}.
     *
     * @param start
     *      The byte offset in the input file where the write operation starts.
     *
     * @return
     *      if the file is still being written, this method writes the file
     *      until the last newline character and returns the offset to start
     *      the next write operation.
     */
    public long writeLogTo(long start, int size, OutputStream out) throws IOException {
        if (size <= 0) {
            return 0;
        }

        CountingOutputStream os = new CountingOutputStream(out);

        Session f = source.open();
        f.skip(start);

        //long end = start + size;

        byte[] buf = new byte[size];
        int sz;
        if ((sz=f.read(buf))>=0) {
            os.write(buf,0,sz);
        }
/*
        if(completed) {
        } else {
            ByteBuf buf = new ByteBuf(null,f, size);
            HeadMark head = new HeadMark(buf);
            TailMark tail = new TailMark(buf);

            int readLines = 0;
            while(tail.moveToNextLine(f) && readLines++ < MAX_LINES_READ) {
                head.moveTo(tail, os);
                if (buf.isFull() || os.getCount() >= end) {
                    break;
                }
            }
            head.finish(os);
        }
*/

        f.close();
        os.flush();

        return os.getCount()+start;
    }
 
开发者ID:fabric8io,项目名称:fabric8-jenkins-workflow-steps,代码行数:52,代码来源:LargeText.java


注:本文中的org.apache.commons.io.output.CountingOutputStream.getCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。