在第20行,PrintWriter
不会打印附加到'hold'变量的字符串。 'hold'变量是正确的,因为它稍后会用适当的字符串打印到控制台两行。有关PrintWriter
打印空行的原因吗?
代码:
public void accepter() throws IOException{
handler han = new handler();
Thread thread2 = new Thread(han);
FileWriter fw = new FileWriter(transferFile, true);
PrintWriter writer = new PrintWriter(fw);
System.out.println("Reciver started");
thread2.start();
while(true){
aSocket = sSocket.accept();
input = new BufferedReader(new InputStreamReader(aSocket.getInputStream()));
hold = input.readLine();
if(hold != null){
writer.println(hold);
writer.flush();
System.out.println(hold);
}
}
}