You will need to modify it slightly - csvArray is an ArrayList ....
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(csvFile, true));
for (int i = 0; i < csvArray.size(); i++) {
bos.write(((String)csvArray.get(i)).getBytes());
}
I am reading a CSV file with fields and sending to the server for inserting. However it writes only the last line and the earlier data is lost. Its still overwriting. I am giving my code here:
BufferedOutputStream bos = null;
//Processing of the data starts here
if (firstchar.equals("I") {
bos = new BufferedOutputStream(new FileOutputStream("Data.txt");
bos.write(buf, 0, buf.length);
}
buf[0] = (byte) 'y'; // Just for testing
packet = new DatagramPacket(buf, len, address, port);
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.