Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9302389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:14:42+00:00 2026-06-18T23:14:42+00:00

While reading here and creating a large Object to send and receive using JsonWriter

  • 0

While reading here and creating a large Object to send and receive using JsonWriter and JsonReader. I wanted to keep track of total bytes sent.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T23:14:43+00:00Added an answer on June 18, 2026 at 11:14 pm

    There’s nothing in JsonWriter or JsonReader that is going to provide that for you.

    Really the only way to do it would be to wrap/extend the Reader or Writer you’re currently passing to JsonReader/JsonWriter and keep track of the bytes being read/written in/out.

    Edit to add: As an example you could do something like:

    class MyWriterWrapper extends Writer {
    
        private Writer realWriter;
        private int bytesWritten;
    
        public MyWriterWrapper(Writer realWriter) {
            super(); 
            this.realWriter = realWriter;
        }
    
        public int getBytesWritten() {
            return bytesWritten;
        }
    
        @Override
        public Writer append(CharSequence csq) throws IOException {
             realWriter.append(csq);
             bytesWritten += csq.length();
             return this;
        }
    
        // Implement/Override all other Writer methods the same way
    
    }
    

    It’d be a lot cleaner if Writer was an interface but … meh, what can you do. If you know you’re only ever going to use one type of Writer (say, a BufferedWriter) you could extend that, override all the methods and re-call the methods on this instead of the private realWriter instance passed in via the constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While reading through another question here, on creating a URL shortening service, it was
Found this while reading the Neo4j manual, specifically here , I found the sentence:
While I'm busy here reading the FastCGI documentation (yeah, reading the 'friendly' manual), does
Here's my code for reading my db data: OdbcDataReader rdr = cmd.ExecuteReader(); while (rdr.Read())
While reading from serial port I am using serialport.read(xyz,0,4) where xyz is a byte
While reading a revision history here at stackoverflow I noticed a great usability pattern
Been reading here for quite a while now.. But cant seem to figure out
I am starting PHP. While reading form from here I came across this text,
While reading this class BitmapFactory I noticed that almost all methods inside are static.
While reading the K&R 2nd edition I noticed that the programs always began with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.