When I receive the file, it adds the WHOLE file into the 0 index of 'data'. How do I make it so each line of the file being received goes into a new index, basically adding like I'm trying to do.
public Downloader(Socket socket) {
List<String> data = new ArrayList<String>();
try {
InputStream input = socket.getInputStream();
byte[] buffer = new byte[socket.getReceiveBufferSize()];
int bytesReceived = 0;
while ((bytesReceived = input.read(buffer)) > 0) {
String line = new String(buffer, 0, bytesReceived);
if (line.trim().length() > 0) {
data.add(line);
}
}
Data.rawData = data;
input.close();
socket.close();
} catch (Exception e) {
e.printStackTrace();
}
}