-1

I'm trying to export a CSV file with the help of opencsv 3.7. I need to limit the size of my file and I didn't figure how to do it yet. file.size() doesn't help in this situation.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

1

You could implement a custom FileOutputStream that counts bytes written by it's write() method and close the stream if the maximum is reached.

Or you can ask the stream before writing the next csv-line to determine if there is still room.

Also take into account the file-encoding (do you want to count bytes, or characters?)

Rob Audenaerde
  • 19,195
  • 10
  • 76
  • 121