I am trying to write a single huge file in Java using multiple threads.
I have tried both FileWriter
and bufferedWriter
classes in Java.
The content being written is actually an entire table (Postgres) being read using CopyManager
and written. Each line in the file is a single tuple from the table and I am writing 100s of lines at a time.
Approach to write:
The single to-be-written file is opened by multiple threads in append mode. Each thread thereafter tries writing to the file file.
Following are the issues I face:
Filewriter
, once a while I see a single black line in the file.Any suggestions, how to avoid this data integrity issue?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With