本文整理汇总了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;
}
示例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();
}
示例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();
}
示例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();
}
};
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}