Count the bytes written to file via BufferedWriter formed by GZIPOutputStream

后端 未结 4 825
深忆病人
深忆病人 2021-01-15 21:24

I have a BufferedWriter as shown below:

BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
        new GZIPOutputStream( hdfs.cr         


        
4条回答
  •  悲&欢浪女
    2021-01-15 21:34

    You can use the CountingOutputStream from Apache commons IO library.

    Place it between the GZIPOutputStream and the file Outputstream (hdfs.create(..)).

    After writing the content to the file you can read the number of written bytes from the CountingOutputStream instance.

提交回复
热议问题