-1
的插座編程PrintStream.println()的替代,我不希望使用的println()方法。請給我任何println()方法的替代方法。當我使用print()或write()時,我的套接字程序沒有收到請求,也沒有發送響應。請幫幫我。如何使用PrintStream.print()在Java中
服務器代碼
in = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
out = new PrintStream(socket.getOutputStream(), true, "UTF-8");
s = in.readLine();
if (s.equals("")) {
try {
socket.close();
in.close();
out.close();
} catch (IOException e) {
}
}
.
.
.
.
.
.
String b;
if (timeInMin > 0 && timeInMin <= 600000) {
b = "B:1";
out.println(b); // send data to client
} else {
b = "B:0";
out.println(b); // send data to client
}
try {
} catch (InterruptedException ex) {
}
}
} catch (IOException e) {
out.println(e);
} finally {
try {
socket.close();
in.close();
out.close();
} catch (IOException e) {
}
}