FileOutputStream fos = new FileOutputStream(new File("str" + i + ".txt",true)); // 이렇게 구성하는 것이 좋다고 함. 왜?
BufferedOutputStream bos = new BufferedOutputStream(fos,1024);
// 2048(소켓출력일때),1024(파일일때),512(네트워크)가 적당하다고함.
DataOutputStream dos = new DataOutputStream(bos);
1.
FileOutputStream fo = new FileOutputStream(new File("str" + i + ".txt",true));
DataOutputStream dos = new DataOutputStream(fo);
dos.writeChars(String.valueOf(clientMessage+'\n'));
2.
BufferedWriter file = new BufferedWriter(new FileWriter("filename")); // 파일 덮어쓰기
BufferedWriter file = new BufferedWriter(new FileWriter("str" + i + ".txt", true)); // 파일 이어쓰기
BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
clientMessage = inFromClient.readLine();
file.write(clientMessage);
file.newLine();