Skip to content

Commit c4fcac8

Browse files
Apply Spotless formatting
1 parent e0a5450 commit c4fcac8

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/main/java/com/mycmd/commands/PingCommand.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,30 @@
2020
* for both Windows and Unix-like systems.
2121
*
2222
* <p>Usage:
23+
*
2324
* <ul>
24-
* <li>ping &lt;hostname&gt; : Ping with default count (4 packets)</li>
25-
* <li>ping &lt;hostname&gt; -t : Ping continuously until stopped (Windows/Unix)</li>
26-
* <li>ping &lt;hostname&gt; -n &lt;count&gt; : Ping with specified packet count</li>
27-
* <li>ping &lt;hostname&gt; -w &lt;timeout&gt; : Set timeout in milliseconds (Windows)</li>
28-
* <li>ping &lt;hostname&gt; -l &lt;size&gt; : Set buffer size (Windows)</li>
25+
* <li>ping &lt;hostname&gt; : Ping with default count (4 packets)
26+
* <li>ping &lt;hostname&gt; -t : Ping continuously until stopped (Windows/Unix)
27+
* <li>ping &lt;hostname&gt; -n &lt;count&gt; : Ping with specified packet count
28+
* <li>ping &lt;hostname&gt; -w &lt;timeout&gt; : Set timeout in milliseconds (Windows)
29+
* <li>ping &lt;hostname&gt; -l &lt;size&gt; : Set buffer size (Windows)
2930
* </ul>
3031
*
3132
* <p>Examples:
33+
*
3234
* <ul>
33-
* <li>ping google.com</li>
34-
* <li>ping 8.8.8.8</li>
35-
* <li>ping google.com -n 10</li>
36-
* <li>ping google.com -t</li>
37-
* <li>ping 1.1.1.1 -n 5 -w 1000</li>
35+
* <li>ping google.com
36+
* <li>ping 8.8.8.8
37+
* <li>ping google.com -n 10
38+
* <li>ping google.com -t
39+
* <li>ping 1.1.1.1 -n 5 -w 1000
3840
* </ul>
3941
*
4042
* <p>Statistics displayed:
43+
*
4144
* <ul>
42-
* <li>Packets: Sent, Received, Lost (with percentage)</li>
43-
* <li>Round-trip times: Minimum, Maximum, Average</li>
45+
* <li>Packets: Sent, Received, Lost (with percentage)
46+
* <li>Round-trip times: Minimum, Maximum, Average
4447
* </ul>
4548
*
4649
* <p>Note: This implementation uses the system's native ping command for accurate network
@@ -108,8 +111,7 @@ private void displayHelp() {
108111
System.out.println(
109112
" -w timeout Timeout in milliseconds to wait for each reply.");
110113
} else {
111-
System.out.println(
112-
" -c count Number of echo requests to send (Unix-style).");
114+
System.out.println(" -c count Number of echo requests to send (Unix-style).");
113115
System.out.println(
114116
" -i interval Wait interval seconds between sending each packet.");
115117
}
@@ -154,8 +156,7 @@ private void executePing(String[] command, String host, String resolvedIP)
154156
ProcessBuilder pb = new ProcessBuilder(command);
155157
Process process = pb.start();
156158

157-
BufferedReader reader =
158-
new BufferedReader(new InputStreamReader(process.getInputStream()));
159+
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
159160
BufferedReader errorReader =
160161
new BufferedReader(new InputStreamReader(process.getErrorStream()));
161162

@@ -212,7 +213,8 @@ private void extractTimeFromLine(String line, PingStatistics stats, String os) {
212213
}
213214

214215
// Count sent/received packets
215-
if (line.toLowerCase().contains("reply from") || line.toLowerCase().contains("bytes from")) {
216+
if (line.toLowerCase().contains("reply from")
217+
|| line.toLowerCase().contains("bytes from")) {
216218
stats.received++;
217219
stats.sent++;
218220
} else if (line.toLowerCase().contains("request timed out")

0 commit comments

Comments
 (0)