Package org.apache.commons.io.output

Examples of org.apache.commons.io.output.CountingOutputStream


  }
   
  public void open( final CharSequence suffix ) throws IOException {
    basenameSuffix = basename + suffix;
    documentsOutputBitStream = new OutputBitStream( basenameSuffix + SimpleCompressedDocumentCollection.DOCUMENTS_EXTENSION );
    termsOutputStream = new CountingOutputStream( new FastBufferedOutputStream( new FileOutputStream( basenameSuffix + SimpleCompressedDocumentCollection.TERMS_EXTENSION ) ) );
    nonTermsOutputStream = exact ? new CountingOutputStream( new FastBufferedOutputStream( new FileOutputStream( basenameSuffix + SimpleCompressedDocumentCollection.NONTERMS_EXTENSION ) ) ) : null;
    documentOffsetsObs = new OutputBitStream( basenameSuffix + SimpleCompressedDocumentCollection.DOCUMENT_OFFSETS_EXTENSION );
    termOffsetsObs = new OutputBitStream( basenameSuffix + SimpleCompressedDocumentCollection.TERM_OFFSETS_EXTENSION );
    nonTermOffsetsObs = exact? new OutputBitStream( basenameSuffix + SimpleCompressedDocumentCollection.NONTERM_OFFSETS_EXTENSION ) : null;
    fieldContent = new IntArrayList();
View Full Code Here


       
        MessageFormatter messageFormatter = BaseUtils.getMessageFormatter(msgContext);
        OMOutputFormat format = BaseUtils.getOMOutputFormat(msgContext);
       
        try {
            CountingOutputStream os = new CountingOutputStream(
                    responseFile.getContent().getOutputStream(append));
            try {
                messageFormatter.writeTo(msgContext, format, os, true);
            } finally {
                os.close();
            }
           
            // update metrics
            metrics.incrementMessagesSent(msgContext);
            metrics.incrementBytesSent(msgContext, os.getByteCount());
           
        } catch (FileSystemException e) {
            if (lockingEnabled) {
                VFSUtils.releaseLock(fsManager, responseFile);
            }
View Full Code Here

        Writer(OutputStream output, boolean compress) throws IOException {
            if (output == null) {
                throw new IllegalArgumentException("output must not be null"); //$NON-NLS-1$
            }
            this.counter = new CountingOutputStream(output);
            this.output = new ZipOutputStream(counter);
            this.output.setMethod(ZipOutputStream.DEFLATED);
            if (compress == false) {
                this.output.setLevel(0);
            }
View Full Code Here

                        // エントリを追加
                        addEntry = true;
                        fileName = FileNameUtil.createSendExportFileName(tableName, fileNameMap);
                        OutputStream output = writer.openNext(FileList.content(fileName));
                        try {
                            CountingOutputStream counter = new CountingOutputStream(output);
                            ModelOutput<T> modelOut = factory.createModelOutput(counter);
                            T model = factory.createModelObject();
                            LOG.info("TG-COLLECTOR-02004",
                                    tableName, path.toString(), fileName);

                            // 入力を読み込み、Model→TSV変換を行う
                            boolean nextFile = false;
                            while (input.readTo(model)) {
                                // Modolを書き出す
                                modelOut.write(model);
                                count++;
                                // 最大ファイルサイズに達したかチェックする
                                // charからbyteに変換する部分でバッファされるため、
                                // 必ずしも分割サイズで分割されない。(バッファ分の誤差がある)
                                if (counter.getByteCount() > maxSize) {
                                    nextFile = true;
                                    break;
                                }
                            }
                            modelOut.close();
View Full Code Here

    @Override
    public void writeTo(OutputStream out, String[] ignoreHeaders)
            throws MessagingException, IOException {
        if (bytesSent == -1) {
            CountingOutputStream countingOut = new CountingOutputStream(out);
            super.writeTo(countingOut, ignoreHeaders);
            bytesSent = countingOut.getByteCount();
        } else {
            super.writeTo(out, ignoreHeaders);
        }
    }
View Full Code Here

     *      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, Writer w) throws IOException {
        CountingOutputStream os = new CountingOutputStream(new WriterOutputStream(w));

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

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

            while(tail.moveToNextLine(f)) {
                head.moveTo(tail,os);
            }
            head.finish(os);
        }

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

        return os.getCount()+start;
    }
View Full Code Here

       
        MessageFormatter messageFormatter = BaseUtils.getMessageFormatter(msgContext);
        OMOutputFormat format = BaseUtils.getOMOutputFormat(msgContext);
       
        try {
            CountingOutputStream os = new CountingOutputStream(
                    responseFile.getContent().getOutputStream(append));
            try {
                messageFormatter.writeTo(msgContext, format, os, true);
            } finally {
                os.close();
            }
           
            // update metrics
            metrics.incrementMessagesSent(msgContext);
            metrics.incrementBytesSent(msgContext, os.getByteCount());
           
        } catch (FileSystemException e) {
            if (lockingEnabled) {
                VFSUtils.releaseLock(fsManager, responseFile);
            }
View Full Code Here

    @Override
    public void writeTo(OutputStream out, String[] ignoreHeaders)
            throws MessagingException, IOException {
        if (bytesSent == -1) {
            CountingOutputStream countingOut = new CountingOutputStream(out);
            super.writeTo(countingOut, ignoreHeaders);
            bytesSent = countingOut.getByteCount();
        } else {
            super.writeTo(out, ignoreHeaders);
        }
    }
View Full Code Here

            final ISWFWriter writer = new SWFWriter(swf, Header.Compression.NONE);
            final String outputFileNameWithExt = outputBaseName + ".swf";
            final File outputFile = new File(outputDirectoryName + outputFileNameWithExt);
            try
            {
                CountingOutputStream output = new CountingOutputStream(
                        new BufferedOutputStream(new FileOutputStream(outputFile)));

                writer.writeTo(output);
                output.flush();
                output.close();
                writer.close();

                out.format("%s, %d bytes written in %5.3f seconds\n",
                        outputFile.toString(),
                        output.getByteCount(),
                        (System.nanoTime() - startTime) / 1e9 );
            }
            catch (IOException e)
            {
                problemQuery.add(new FileWriteProblem(e));
View Full Code Here

        // Ensure that the directory for the SWF exists.
        final File outputDirectory = new File(outputFile.getAbsoluteFile().getParent());
        outputDirectory.mkdirs();

        // Write out the SWF, counting how many bytes were written.
        final CountingOutputStream output =
                new CountingOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile)));
        writeTo(output);
        output.flush();
        output.close();
        close();

        final int swfSize = output.getCount();
        return swfSize;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.io.output.CountingOutputStream

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.