Skip to content

Commit eaa4281

Browse files
github-actionsgithub-actions
authored andcommitted
Formatted with Google Java Formatter
1 parent 19363ec commit eaa4281

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/main/java/com/examplehub/basics/network/SocketClient.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ public static void main(String[] args) throws IOException {
1616
clientSocket.close();
1717
System.out.println("disconnected.");
1818
}
19-
private static void handle(InputStream inputStream, OutputStream outputStream) throws IOException {
19+
20+
private static void handle(InputStream inputStream, OutputStream outputStream)
21+
throws IOException {
2022
var writer = new BufferedWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
2123
var reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
2224
Scanner scanner = new Scanner(System.in);
2325
System.out.println("[server] " + reader.readLine());
24-
for (;;) {
26+
for (; ; ) {
2527
System.out.print(">>> "); // 打印提示
2628
String s = scanner.nextLine(); // 读取一行输入
2729
writer.write(s + System.lineSeparator());
28-
// writer.newLine();
30+
// writer.newLine();
2931
writer.flush();
3032
String resp = reader.readLine();
3133
System.out.println("<<< " + resp);

src/main/java/com/examplehub/basics/network/SocketServer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ static class ServerHandler implements Runnable {
1212
public ServerHandler(Socket socket) {
1313
this.socket = socket;
1414
}
15+
1516
public void run() {
1617
try (InputStream inputStream = this.socket.getInputStream()) {
17-
try(OutputStream outputStream = this.socket.getOutputStream()) {
18+
try (OutputStream outputStream = this.socket.getOutputStream()) {
1819
handle(inputStream, outputStream);
1920
}
2021
} catch (Exception e) {
@@ -52,6 +53,6 @@ public static void main(String[] args) throws IOException {
5253
System.out.println("connected from " + socket.getRemoteSocketAddress());
5354
new Thread(new ServerHandler(socket)).start();
5455
}
55-
//TODO
56+
// TODO
5657
}
5758
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.examplehub.basics.network;
22

33
class SocketServerTest {
4-
//TODO
5-
}
4+
// TODO
5+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy